简体   繁体   English

创建COM组件和ActiveX控件

[英]Create COM component and ActiveX controls

Is is possible to create COM component and ActiveX controls in .Net (using c# language). 是否可以在.Net中创建COM组件和ActiveX控件(使用c#语言)。 I searched internet but i could`t get anything. 我搜索互联网,但我什么都得不到。

Thanks, 谢谢,
santhosh santhosh

Declare an interface and implement it with class. 声明一个接口并用class实现它。
If you have parameters/return values that are not OLE Automation compatible (custom structs, enums and so on), you might need to decorate them with the MarshalAs attribute . 如果您有不兼容OLE自动化的参数/返回值(自定义结构,枚举等),您可能需要使用MarshalAs属性来装饰它们。
Add the GUID attribute to both. GUID属性添加到两者。
Add the COMVisible attribute to both. COMVisible属性添加到两者。 Alternatively, you can mark the assembly with it. 或者,您可以使用它标记装配
Use tlbexp to generate a type library for native clients. 使用tlbexp为本机客户端生成类型库。

Yes, it is possible, there is this article in CodeProject . 是的,有可能, CodeProject中有这篇文章。 A friend of mine tried it and had some trouble accessing the COM-object from his unmanaged app, though, so there are some pitfalls. 我的一个朋友尝试了它并且从他的非托管应用程序访问COM对象时遇到了一些麻烦,所以有一些陷阱。

I think you're looking for information on the "COM Callable Wrapper". 我想你正在寻找关于“COM Callable Wrapper”的信息。 Google for that, or a basic intro is here (I haven't read it): http://www.dnzone.com/ShowDetail.asp?NewsId=126 谷歌为此,或基本介绍在这里(我还没看过): http ://www.dnzone.com/ShowDetail.asp?NewsId = 126

Alan Gordon的.Net和COM互操作性手册ISBN 0-13-046130-X是一个必不可少的资源,如果你做了很多互操作的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM