How do I generate COM interop proxies into C# source code?

ε祈祈猫儿з 提交于 2019-12-01 17:46:35

问题


This questions is a follow up on an answer by Paul Alexander to the question "Should interop assemblies be signed?".

Depending on how complex your Interop assemblies are - you can generate the proxy code into a separate .CS/.VB file and compile it directly into your assembly. Then you won't have to worry about strong name issues.

How would I go about generating the interop proxy code for a COM library into C# source code?

I guess it could be done with tlbimp and then extracting the source with Reflector. Has anyone done this or is there a simpler way?


回答1:


Take a look at the following MSDN article:

  • How to: Create Wrappers Manually (Talks about how to create your interop assembly manually.)

Once you've got the interop assembly, use a tool like Reflector to disassemble it and generate the raw C# source. Reflector.FileDisassembler makes this really easy.

Now you can include the generated C#/VB sources directly into your assembly.




回答2:


I do not know simpler way, and extract interface descriptions via Reflector. However in VS 2010 Microsoft will do this for you automatically.



来源:https://stackoverflow.com/questions/1058289/how-do-i-generate-com-interop-proxies-into-c-sharp-source-code

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