更新时间:2023-02-16 14:50:55
我建议您用命令行编译C#代码并创建一个.net模块:
csc / target:module /addmodule:mfoo.obj bar.cs
然后,您可以将其合并到C ++ / CLI代码中与
#using< ; datei.netmodule>
链接/ LTCG。所以你只有一个C ++ / CLI DLL,所有的C#代码里面...
另请参见:
I'm on a C++/CLI project, and I'm trying to embed some DLL files (WPF custom control library) within my executable to avoid having over 9000 DLLs in the same folder. There is a lot of information about embedding a C++/CLI DLL in a C# project (moreover, it is very simple), but the documentation about the reverse seems to be poor.
The closest solution I have found is here: Embedding resource in a C++/CLI project, but unfortunately I can't see my WPFWidget.dll in resources when I open the .exe file with Visual Studio (2008 or 2012).
I suppose I have to create a resource file, but I have never used this kind of file, and I'm a little lost because embedding a DLL in a resource file isn't intuitive to me.
Do you know a proper method which could help me? Thanks!
I suggest you compile your C# code with command line and create a .net module:
csc /target:module /addmodule:mfoo.obj bar.cs
Then you can merge this into the C++/CLI code with
#using <datei.netmodule>
Link with /LTCG. So you have only one C++/CLI DLL, with all the C# code inside...
See also: