1

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();

然后我尝试将第 6 行的 VB 代码转换为 c#:-

object instance = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));

但我无法将实例对象转换为 SiebelHTMLApplication,例如:-

sApp = (SiebelHTMLApplication)instance;

任何人都可以建议我如何设置它吗?

4

3 回答 3

2

Type.GetTypeFromProgID 创建 com 实例,但不创建 Type 对象。

尝试

object instance = Activator.CreateInstance(Type.GetType("Siebel.Desktop_Integration_Application, AssemblyName")); 

您必须将 AssemblyName 替换为包含 Siebel.Desktop_Integration_Application 描述的程序集名称。

于 2013-07-27T12:41:13.660 回答
0

感谢 Vasiliy,最后我通过从对象更改为类型得到了解决方案。然后它现在正在工作!

var siebelDeskType = Activator.CreateInstance(Type.GetTypeFromProgID("Siebel.Desktop_Integration_Application.1"));
            sApp = (SiebelHTMLApplication)siebelDeskType;
于 2013-07-29T07:26:12.940 回答
0

您总是可以导入 Microsoft.VisualBasic 然后只使用CreateObject吗?

于 2013-07-27T13:13:12.953 回答