下面的示例使用对象的 ProgID 创建对象。
[Visual Basic]
Dim MyObject As Object
MyObject = Server.CreateObject("Acme.Component.3")
[C#]
Object MyObject;
MyObject = Server.CreateObject("Acme.Component.3");
[Visual Basic]
Dim MyObject As Object
MyObject = Server.CreateObject("Acme.Component.3")
[C#]
Object MyObject;
MyObject = Server.CreateObject("Acme.Component.3");
我用的是WinForm,没有Server.CreateObject。
object myObj;
然后使用的时候用C#中的拆箱操作就可以了
int i=10;
object obj = i;
int j = (int)obj;
如果想用COM组件,请用.NET封装COM组建,然后使用封装类。可以直接用“添加引用”来完成这项功能。
或者这一部分用VB做。
Microsoft.VisualBasic.Interaction.CreateObject("oaMail.Mail", "172.17.39.19")
其实
oo = CreateObject("oaMail.Mail", "172.17.39.19")
MsgBox(oo.test())
在C#中没有语法错误,只是在编译的时候找不到方法。