通讯C#创建com对象的类型

问题描述:

我正在开发一些使用库的代码.我正在尝试通过

I am developing some code that uses a com-library. I'm trying to create an instance of the class through

Type t = Activator.CreateInstance("TypeID"); 

但是我无法一直得到类型= null.progid已经通过Ole/COM Wever查看了,看来我输入正确了.可能是什么问题?

But I can not get the type it's all the time = null. progid already looked through the Ole / COM Wever, it seems that I did enter it correctly. In what may be prolem?

您是否传递Type ID字符串?尝试先从ProgId获取类型对象:

Are you passing the Type ID string? Try getting the type object from ProgId first:

Type t = Type.GetTypeFromProgID(progID);
object obj = Activator.CreateInstance(t);