通讯C#创建com对象的类型 [英] Com. C# create type of com-object

查看:70
本文介绍了通讯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);

这篇关于通讯C#创建com对象的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆