简体   繁体   English

C++/CLI 中的包装器 C++ clr:safe for C# COM 互操作

[英]Wrapper C++ in C++/CLI clr:safe for C# COM Interop

is there any way to make a wrapper clr:safe for a project in C++ unmanaged?有没有办法为 C++ 中的项目制作包装器 clr:safe 不受管理?

My little story started this way,我的小故事就这样开始了
"Boy, you have to do a project 'C# COM Interop' but this one have to use a 'C++ library' and must result in only 'one' (dll COM)." “男孩,你必须做一个项目‘C# COM Interop’,但这个项目必须使用‘C++ 库’并且必须只生成‘一个’(dll COM)。”
Ok, after a few days searching, I realized that is possible to use C++ library in two ways: adding in Resources and calling with PInvoke or creating a wrapper C++/CLI.好的,经过几天的搜索,我意识到可以通过两种方式使用 C++ 库:添加资源和使用 PInvoke 调用或创建包装器 C++/CLI。 With PInvoke I can not have only one dll(right?).使用 PInvoke 我不能只有一个 dll(对吗?)。 So I opted for the second option "wrapper C++/CLI".所以我选择了第二个选项“wrapper C++/CLI”。 Seemed easy at the beginning, I recompile the library Visual Studio 2005 to 2010, create a CLR project (with keypair.snk and re-signed) added the library.一开始看起来很简单,我重新编译了 Visual Studio 2005 到 2010 的库,创建了一个 CLR 项目(带有 keypair.snk 并重新签名)添加了该库。 Works, \0/ Now I will use the ILMerge?工作,\0/ 现在我将使用 ILMerge? ohhhoo what is this: Only clr?safe? ohhhoo 这是什么:只有 clr?安全? Why, OK: I try to recompile C++/CLI to clr.safe but erros appears...为什么,好的:我尝试将 C++/CLI 重新编译为 clr.safe 但出现错误...

How can I fix this?我怎样才能解决这个问题?

Thanks in advanced,先谢谢了,

ILMerge isn't the right tool for this. ILMerge 不是解决此问题的正确工具。

Instead, you compile the C# to a .netmodule, and pass that to the C++/CLI linker along with all the C++/CLI object files.相反,您将 C# 编译为 .net 模块,并将其与所有 C++/CLI object 文件一起传递给 C++/CLI linker。

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

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