且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将DLL嵌入到C ++ / CLI可执行文件中?

更新时间:2023-02-16 14:33:09

我建议您使用命令行编译C#代码并创建一个.net模块:

I suggest you compile your C# code with command line and create a .net module:

csc /target:module /addmodule:mfoo.obj bar.cs

然后,您可以将此合并到C / CLI代码中

Then you can merge this into the C++/CLI code with

#using <datei.netmodule>

链接到/ LTCG。所以你只有一个C ++ / CLI DLL,里面有所有的C#代码。

Link with /LTCG. So you have only one C++/CLI DLL, with all the C# code inside...

另请参见:

  • http://blogs.msdn.com/b/texblog/archive/2007/04/05/linking-native-c-into-c-applications.aspx
  • How to link C# and C++ assemblies into a single executable?