如何生成COM互操作代理到C#源$ C ​​$ C?操作、COM

2023-09-03 05:58:25 作者:笑拥冷风

此问题上的answer通过保罗·亚历山大以问题的应该互操作程序集签名?。

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

根据多么复杂的互操作组件是 - 你可以生成代理code到一个单独的.CS / .vb文件,并直接编译成汇编。然后,你将不必担心强名称的问题。

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.

我怎么会去生成的互操作代理$ C $下一个COM库为C#源$ C ​​$ C?

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

我想这可能与TLBIMP,然后用与反射源来完成。有没有人这样做还是有一个更简单的方法?

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?

推荐答案

看看下面的MSDN文章:

Take a look at the following MSDN article:

如何:创建包装手动(谈如何创建您的互操作手工组装。) How to: Create Wrappers Manually (Talks about how to create your interop assembly manually.)

一旦你拿到了互操作程序集,使用类似反射的一个工具,拆开它,并生成原始的C#源。 Reflector.FileDisassembler 使这很容易。

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.

现在,您可以直接包含生成的C#/插入组件VB的来源。

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