oleobject alternative c#

时间:2012-09-28 00:29:21

标签: c# ole powerbuilder

我需要模仿powerbuilder 11.5到C#3.0的部分代码。在powerbuilder中,代码具有oleobject并使用connecttonewobject连接到对象。有人能告诉我在C#中的等价物以及在这里使用的内容。谢谢!

1 个答案:

答案 0 :(得分:2)

这是使用C#动态属性的基本示例(就像pb对象一样)

// get the class id from name
Type myComType = Type.GetTypeFromProgID("SAP.BAPI");

// equal to connect to ojbect in PB
dynamic myComInstance = Activator.CreateInstance(myComType, false);

// calling function equivalent to oleobject.function in PB
myComInstance.ShowDialog("Hello World");