VB6 Code:
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# Code :-
c#代码:-
SiebelHTMLApplication sApp = new SiebelHTMLApplication();
SiebelService sService = new SiebelService();
SiebelPropertySet sPsIn = new SiebelPropertySet();
SiebelPropertySet sPsOut = new SiebelPropertySet();
Then I try to convert line#6 of VB code to c# as :-
然后我试着将VB代码的第6行转换为c# as:-
object instance = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
but I couldn't casting instance object to SiebelHTMLApplication like :-
但是我不能将实例对象强制转换为SiebelHTMLApplication,比如:-
sApp = (SiebelHTMLApplication)instance;
Can any one suggest me an idea how to set it ?
谁能给我建议一下如何设置它吗?
3 个解决方案
#1
2
Type.GetTypeFromProgID creates the com instance but not the Type object.
类型。GetTypeFromProgID创建com实例,而不是类型对象。
Try
试一试
object instance = Activator.CreateInstance(Type.GetType("Siebel.Desktop_Integration_Application, AssemblyName"));
You have to replace AssemblyName with the name of the Assembly which contains the Siebel.Desktop_Integration_Application description.
必须用包含Siebel的程序集的名称替换程序集名称。Desktop_Integration_Application描述。
#2
0
You could always import Microsoft.VisualBasic and then just use CreateObject ?
你可以一直导入微软。VisualBasic然后使用CreateObject ?
#3
0
Thank to Vasiliy, Finally I got the solution by changing from object to type. Then It's working now !!
谢谢Vasiliy,最终我通过对象到类型的转换得到了解决方案。那现在就开始工作了!!
var siebelDeskType = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
sApp = (SiebelHTMLApplication)siebelDeskType;
#1
2
Type.GetTypeFromProgID creates the com instance but not the Type object.
类型。GetTypeFromProgID创建com实例,而不是类型对象。
Try
试一试
object instance = Activator.CreateInstance(Type.GetType("Siebel.Desktop_Integration_Application, AssemblyName"));
You have to replace AssemblyName with the name of the Assembly which contains the Siebel.Desktop_Integration_Application description.
必须用包含Siebel的程序集的名称替换程序集名称。Desktop_Integration_Application描述。
#2
0
You could always import Microsoft.VisualBasic and then just use CreateObject ?
你可以一直导入微软。VisualBasic然后使用CreateObject ?
#3
0
Thank to Vasiliy, Finally I got the solution by changing from object to type. Then It's working now !!
谢谢Vasiliy,最终我通过对象到类型的转换得到了解决方案。那现在就开始工作了!!
var siebelDeskType = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
sApp = (SiebelHTMLApplication)siebelDeskType;