如何将 .NET 应用程序编译为本机代码? [英] How to compile a .NET application to native code?

查看:35
本文介绍了如何将 .NET 应用程序编译为本机代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想在 .NET 框架不可用的机器上运行 .NET 应用程序;有没有办法将应用程序编译为本机代码?

Let's say I want to run a .NET application on a machine where the .NET framework is not available; Is there any way to compile the application to native code?

推荐答案

Microsoft 有一篇文章描述了如何将MSIL编译为本机代码

Microsoft has an article describing how you can Compile MSIL to Native Code

您可以使用 Ngen.

本机图像生成器 (Ngen.exe)是一个工具,可以提高托管应用程序的性能.Ngen.exe 创建本机映像,其中是包含编译的文件特定于处理器的机器代码,以及将它们安装到本机映像中缓存在本地计算机上.这运行时可以使用来自缓存而不是使用即时(JIT) 编译器编译原件组装.

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

不幸的是,您仍然需要框架中的库才能运行您的程序.我所知道的 MS .Net 框架 SDK 没有任何功能可以让您将所有必需的文件编译成单个可执行文件

Unfortunately, you still need the libraries from the framework in order to run your program. There's no feature that I know of with the MS .Net framework SDK that allows you to compile all the required files into a single executable

这篇关于如何将 .NET 应用程序编译为本机代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆