在通过C#整合iDesktop的时候报了个错了,具体代码如下
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
Application.ActiveApplication = new Application();
Application currentApplication = Application.ActiveApplication;
//打开登陆窗口
FormAccess form = new FormAccess();
//如果登陆成功,则根据用户加载不同的插件
if (form.ShowDialog() == DialogResult.OK)
{
//如果是 admin 用户,则加载完整的 Default 工作环境
if (form.UserName == "admin")
{
//设置加载的工作环境
currentApplication.WorkEnvironmentManager.ActiveWorkEnvironmentName = "Default";
}
//如果是viewer用户,则在Default工作环境中过滤掉高级插件
else if (form.UserName == "viewer")
{
currentApplication.WorkEnvironmentManager.ActiveWorkEnvironmentName = "Default";
//注册插件加载时事件
currentApplication.PluginManager.PluginLoading += new PluginLoadingEventHandler(PluginManager_PluginLoading);
}
//初始化程序并运行
currentApplication.SplashForm.Show();
try
{
currentApplication.Initialize();
}
catch (Exception ex)
{
currentApplication.MessageBox.Show(string.Concat("初始化应用程序失败.", ex.Message));
}
finally
{
currentApplication.SplashForm.Close();
}
currentApplication.Run();
currentApplication.Exit();
在currentApplication.Run(); 这一行报错:Application.ActiveApplication.MainForm is NULL.
用的是iDesktop 9D,环境变量和许可都配置了