如何将.NET exe转换为本机Win32 exe?

如何将.NET exe转换为Win32 exe? (我没有代码)目的是使用wine在Linux中运行应用程序。 我认为.NET exe不能在wine中运行,我不想使用mono。

根据它的.NET版本以及它使用的库,您可以尝试在Mono下运行它,而无需将IL编译为本机代码。

大多数Linux发行版都在其包管理系统下提供。

请参阅: http : //www.mono-project.com/Main_Page了解更多详情

另一种方法是使用NGen进行编译( http://blogs.msdn.com/clrcodegeneration/archive/2007/09/15/to-ngen-or-not-to-ngen.aspx )。 但我不确定它会在WINE下运作。

根据您的框架版本,它可以与Wine中的Wine .Net Framework兼容性一起使用

这对你来说可能是一个困难的解决方案,但为了完整起见,我在这里提到它。

你可以用VMWare的Thinapp包装一个.net应用程序。 我相信这会产生win32可执行文件。

https://www.vmware.com/products/thinapp

也许它会在单声道下运行?

使用带有静态库的提前编译器。 单声道的Aka mkbundle

Mono带有一个命令行接口到单声道JIT编译器来编译AOT(提前)。 您可以使用它来创建静态链接的.o,然后您可以使用一个简单的包装器来运行,该包装器使用目标文件调用单声道运行时嵌入器。 如果然后静态链接到单声道库,则不会对已安装的.NET框架有任何外部依赖性。

当然,你必须运送所有静态链接的库或最终得到一个hughe exe但是嘿,这就是你要求的

mono --aot=static static Create an ELF object file (.o) which can be statically linked into an executable when embedding the mono runtime. When this option is used, the object file needs to be registered with the embedded runtime using the mono_aot_register_module function which takes as its argument the mono_aot_module__info global symbol from the object file: extern void *mono_aot_module_hello_info; mono_aot_register_module (mono_aot_module_hello_info); 

虽然我在linux上使用它,但我并不完全确定它在Windows上同样适用。

更新记得mkbundle工具:

 sehe@sehelap:~$ mkbundle --static test.exe -o hello OS is: Linux Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking. See http://www.mono-project.com/Licensing for details on licensing. Sources: 1 Auto-dependencies: False embedding: /home/sehe/test.exe Compiling: as -o temp.o temp.s cc -o hello -Wall `pkg-config --cflags mono` temp.c `pkg-config --libs-only-L mono` -Wl,-Bstatic -lmono -Wl,-Bdynamic `pkg-config --libs-only-l mono | sed -e "s/\-lmono //"` temp.o Done sehe@sehelap:~$ ./hello hello world sehe@sehelap:~$ ldd hello linux-gate.so.1 => (0xb7875000) libdl.so.2 => /lib/libdl.so.2 (0xb785f000) libpthread.so.0 => /lib/libpthread.so.0 (0xb7845000) libm.so.6 => /lib/libm.so.6 (0xb781e000) libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb7819000) librt.so.1 => /lib/librt.so.1 (0xb7810000) libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0xb7741000) libc.so.6 => /lib/libc.so.6 (0xb75e4000) /lib/ld-linux.so.2 (0xb7876000) libpcre.so.3 => /lib/libpcre.so.3 (0xb75af000) 

根本不可能。 对于托管代码,您需要运行某种VM。在Linux中,您可以使用Mono或dotgnu portable.net。 也许一些超高级版本的葡萄酒曾经能够运行MS .net框架?