VB6代码:
Dim oApplication As SiebelHTMLApplication
Dim oBS As SiebelService
Dim oPSIn As SiebelPropertySet
Dim oPSOut As SiebelPropertySet
Dim sActivityId As String
Set oApplication = CreateObject("Siebel.Desktop_Integration_Application.1")
If oApplication.IsReady Then
Set oBS = oApplication.GetService("Workflow Process Manager")
C#代码: -
SiebelHTMLApplication sApp = new SiebelHTMLApplication();
SiebelService sService = new SiebelService();
SiebelPropertySet sPsIn = new SiebelPropertySet();
SiebelPropertySet sPsOut = new SiebelPropertySet();
然后我尝试将VB代码的第6行转换为c#: -
object instance = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
但我无法将实例对象转换为SiebelHTMLApplication,如: -
sApp = (SiebelHTMLApplication)instance;
任何人都可以建议我如何设置它吗?
答案 0 :(得分:2)
Type.GetTypeFromProgID创建com实例,但不创建Type对象。
尝试
object instance = Activator.CreateInstance(Type.GetType("Siebel.Desktop_Integration_Application, AssemblyName"));
您必须将AssemblyName替换为包含Siebel.Desktop_Integration_Application描述的Assembly的名称。
答案 1 :(得分:0)
您始终可以导入Microsoft.VisualBasic,然后只使用CreateObject?
答案 2 :(得分:0)
感谢Vasiliy,最后我通过从对象更改为类型来获得解决方案。那它现在正在工作!!
var siebelDeskType = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
sApp = (SiebelHTMLApplication)siebelDeskType;