Is it possible to compile .NET IL code into machine code?

I would like to distribute my .NET programs without the .NET platform. Is it possible to compile a .NET program for machine code?

+28
compiler-construction visual-studio
Sep 26 '08 at 17:18
source share
12 answers

Yes, you can precompile Ngen.exe, however this does not eliminate the CLR dependency.

You should also send IL assemblies, the only advantage of Ngen is that your application can start without calling JIT, so you get very fast startup times.

According to CLR Via C #:

In addition, assemblies precompiled using Ngen are usually slower than JIT'ed assemblies, because the JIT compiler can optimize the target machine (32-bit 64-bit? Special registers? Etc.), while NGEN will be the base compilation.

EDIT:

There is some discussion of the above information with Via C # CLR, as some say that you should run Ngen on the target machine only as part of the installation process.

+19
Sep 26 '08 at 17:23
source share

Remotesoft has one: Salamander.NET Linker

I have no experience with him, though.

+19
Sep 26 '08 at 17:23
source share

There are some third party tools that do this, for example.

+7
Sep 26 '08 at 17:25
source share

Another (expensive and proprietary license starts at $ 1,599) that can do this is Xenocode Postbuild . I did not use it myself, although it stood near the gross national product of a small African country and all ...

+5
Sep 26 '08 at 17:40
source share

Is it possible to compile .NET IL code for machine code?

Yes, but the .NET Framework does this for you at runtime (by default) or during installation (ngen). Among other reasons, this IL → machine code is executed separately on each installation machine, so it can be optimized for that particular machine.

I would like to distribute my .NET. programs without the .NET platform. Is it possible to compile .NET. program for machine code?

No, for all purposes and purposes you cannot do this. Third-party workarounds may work in some scenarios, but by then I will no longer consider its “managed code” or “.NET”.

+3
Sep 26 '08 at 18:54
source share

Yes, now you can! Microsoft recently announced the .NET Native , part of the technology that compiles your application with the .NET Native runtime (they call it MRT) into a single binary file (actually one executable and one dynamic library).

See links: http://blogs.msdn.com/b/dotnet/archive/2014/04/02/announcing-net-native-preview.aspx http://blogs.msdn.com/b/dotnet/archive /2014/04/24/dotnetnative-performance.aspx

+3
May 01 '14 at 7:12
source share

For the compilation part of IL2CPU .

+2
Feb 10 '09 at 15:35
source share

I do not think that's possible. You can make a pre-assembled assembly, but you still need a framework.

+1
Sep 26 '08 at 17:21
source share

I think you should not: This is the task of the JIT compiler.

However, you can use ClickOnce or the Windows installer to deploy it so that the missing infrastructure is not such a big problem: you could tell the installer to download the Framework and install it.

+1
Sep 26 '08 at 17:24
source share

If you're just interested in the size of the deployment of the Framework, you can read this .

+1
Sep 26 '08 at 17:47
source share

Check out the MONO project: the mono command with the -aot option. http://www.mono-project.com/AOT

+1
Feb 10 '09 at 17:12
source share

I always thought it would be great to compile C # for machine code directly without a CLR dependency, though ....

0
Sep 26 '08 at 17:44
source share



All Articles