简体   繁体   English

如何在C#中为桌面应用程序创建activeX组件

[英]How do I create an activeX component for a desktop application in C#

I need to create a plug-in (with GUI) for an application that loads them as activeX components (the joy of legacy systems). 我需要为应用程序创建一个插件(带有GUI),将它们作为activeX组件加载(遗留系统的乐趣)。 I've done some googling, but while I can find multiple examples of how to create an activeX component for a web page I can't find any examples for the desktop equivalent. 我已经做了一些谷歌搜索,但虽然我可以找到如何为网页创建一个activeX组件的多个示例,但我找不到桌面等效的任何示例。

You should start with a new Windows Forms Control Library - Project. 您应该从新的Windows窗体控件库 - 项目开始。

In the project-properties dialog, section for your application, click on [Assembly Information ...]. 在项目属性对话框的应用程序部分中,单击[装配信息...]。

Then you will see a checkbox: Make assembly COM visible. 然后,您将看到一个复选框:使程序集COM可见。 Check this option on. 选中此选项。

This is equivalent to having 这相当于拥有

[assembly: ComVisible(true)]

in AssemblyInfo.cs. 在AssemblyInfo.cs中。 All your (public) user-controls should be accessible eg in VB6 projects. 所有(公共)用户控件都应该可以在例如VB6项目中访问。

I didn't expect so much trouble as discussed here 我没想到的讨论这么多麻烦在这里

The main point seems to be: regsvr32 is useless for .net-dlls. 主要观点似乎是: regsvr32对.net-dlls 没用 you should go with regasm.exe 你应该使用regasm.exe

This question is a bit old, but... I was looking for answers to the very same problem. 这个问题有点老了,但是......我一直在寻找同样问题的答案。 Namely, I'm trying to write a driver that ties into an older app via an ActiveX control. 也就是说,我正在尝试编写一个通过ActiveX控件绑定到较旧应用程序的驱动程序。 As a last ditch effort I was wading through msdn and found a link to "All-in-one code framework." 作为最后的努力,我正在通过msdn浏览并找到了“一体化代码框架”的链接。 Among the dozens of samples is one for CSActiveX . 在几十个样本中有一个用于CSActiveX It answered a lot of my questions so I thought I'd share. 它回答了我的很多问题,所以我想我会分享。

One note about the sample it requires a pre-build event so make sure and correct it to point to your copy of rc.exe. 有关该示例的一个注意事项需要预构建事件,因此请确保并更正它以指向您的rc.exe副本。 I needed to change it for vs2010 anyways. 无论如何我需要为vs2010改变它。

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

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