更新时间:2023-02-12 17:09:39
等等,有一个肯定的答案,但显然它是完全邪恶的:
Wait, there is a yes answer, but obviously it's completely evil:
如果您的 C++ 代码不是用/clr:safe 编译的(即它是用/clr 或/clr:pure 编译的),请执行以下操作:
If your C++ code is not compiled with /clr:safe (i.e. it is compiled with /clr or /clr:pure), do the following:
1) 将您的 C++ 代码编译成 .obj 文件
1) compile your C++ code into .obj files
2) 将 C# 代码编译为 .netmodule,使用/AddModule 引用 C++ .obj 文件
2) compile your C# code into a .netmodule, using /AddModule to reference the C++ .obj files
3) 使用 C++ 链接器将 C# netmodule 直接与 C++ 目标文件链接以创建混合语言程序集
3) link the C# netmodule directly with the C++ object files using the C++ linker to create a mixed language assembly
还有这个:将本机 C++ 链接到 C# 应用程序
是的,不要那样做.