How to deploy a COM

主宰稳场 提交于 2019-12-06 22:51:33

I've really never used RegSvr32 with .Net assemblies, rather I use the regasm with the /codebase option:

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe /codebase mydll.dll

You can also use the /tlb option to export the type library and register it.

Of course the easiest way, just create an installer with vstudio and it will do this for you.

Creating a Description of the COM class and Interfaces

.Net assemblies don't include information in Type Library compatible format. So it is necessary for the programmer to run one of two .Net-supplied utilities to extract the assembly description of a class into a Type Library file.

One utility is TLBEXP.EXE, the .Net Type Library Exporter. This command line utility takes as input the name of an assembly DLL file to be converted to a Type Library. The programmer can also specify the name of a Type Library file to be created.

tlbexp ComServer.dll /out:ComServer.tlb

Assembly exported to C:\Magellan\Source\Output\Debug\ComServer.tlb

Once a Type Library has been created, it can be referenced by a COM client to obtain the information necessary for the COM client to bind to the interfaces of the COM class, and activate the COM class at runtime.

Registration of the COM Class and Interfaces

For a COM class to be accessible by the client at runtime, the COM infrastructure must know how to locate the code that implements the COM class. The following command accomplishes this:

regasm ComServer.dll

Your DLL can be put anywhere you wish, but a good choice is C:\Program Files\MyApplication.

http://www.csharphelp.com/archives/archive190.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!