我正在客户端机器上部署一个C#应用程序。应用程序需要访问另一个程序的代码,这样它就可以从另一个应用程序的屏幕上删除文本。它在开发机器上运行良好,但在客户端机器上它抛出了一个错误"ActiveX组件无法创建对象",这就是我收到错误的原因!
private ExtraSession objExtraSession;
private ExtraSessions objExtraSessions;
private ExtraScreen objExtraScreen;
private ExtraArea objExtraArea;
private ExtraSystem objExtraSystem;
protected void sessionInitializer()
{
try
{
objExtraSystem = (ExtraSystem) Microsoft.VisualBasic.Interaction.CreateObject("Extra.system");
if (objExtraSystem == null)
{
MessageBox.Show("Could not create system");
return;
}
objExtraSessions = objExtraSystem.Sessions;
if (objExtraSessions == null)
{
MessageBox.Show("Could not create sessions");
return;
}
if (!System.IO.File.Exists("C:\Users\" + userid + "\Documents\Attachmate\EXTRA!\Sessions\SAS.edp"))
{
MessageBox.Show("File does not exist");
return;
}
objExtraSession = (ExtraSession) Microsoft.VisualBasic.Interaction.GetObject("C:\Users\"+ userid + "\Documents\Attachmate\EXTRA!\Sessions\SAS.edp");
if (objExtraSession == null)
{
MessageBox.Show("Could not create session");
return;
}
if (objExtraSession.Visible == 0)
{
objExtraSession.Visible = 1;
}
objExtraScreen = objExtraSession.Screen;
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Failed to initialize Attachmate sessions");
}
}
该错误是从objExtraSession=(ExtraSession)Microsoft.VisualBasic.Interaction.GetObject("C:\Users\"+userid+"\Documents\Attachmate\EXTRA!\Sessions\SAS.edp")生成的;
我是不是少了一步。请帮帮我。提前谢谢。
最可能的解释是您的开发机器安装了ActiveX控件,但客户端机器没有。阅读控件的部署文档,并执行所说的部署到客户端计算机所需的操作。
感谢您的回复。。。方法GetObject正在创建一个对象,该对象的activex组件未注册。。。我通过找到相应的*.ocx文件并在该文件上调用Regsvr32解决了问题。。。