Compile .NET assembly into x86 machine code
Asked Answered
T

2

11

Is there any way to compile a .NET assembly into native code (i.e for x86) output, that is, without MSIL.

For what I understand if you just specify x86 as architecture this would only change the PE Header to point that out to the JIT, but still the assembly will contain MSIL and will be JITTed as needed.

NGen does produce assembly files for the specified architecture but it's not a compiler, it's designed to improve performance but you do still need the original DLL, the presence of the native image only serves to avoid JIT compiling the assembly but you just can't get that native image and use it, can you?

So, is there any way to actually compile from .NET to native machine code?

Typescript answered 1/6, 2011 at 8:34 Comment(1)
I'd be surprised - wouldn't this entail compiliing large parts of the CLR to assembler as well?Urbanism
F
3

You can do this using the new precompilation technology called .NET Native. Check it out here: http://msdn.microsoft.com/en-US/vstudio/dotnetnative

Currently it is only available for Windows Store Apps. It performs single component linking. So .NET Framework libraries are statically linked into your app. Everything is compiled to native and IL assemblies are no longer deployed.

Forewarn answered 21/4, 2014 at 1:12 Comment(2)
This should be the top answer: .NET Native is a major milestone for C#/.NET, and does what the SO is asking for.Mosquito
@karim: keep in mind that the question was asked 3 years ago :)Fortis
F
10

Spoon Studio (was named Xenocode before) seems to be able to do that: http://spoon.net/Studio/Features.aspx

RemoteSoft also have a product but the website looks quite old: http://www.remotesoft.com/linker/

Fortis answered 1/6, 2011 at 8:50 Comment(1)
Spoon.net is no longer a thing but it is now turbo which basically containerizes a solution which is kinda the opposite of what the original question was about. DotNetNative, with its drawbacks is currently a better approach.Dicrotic
F
3

You can do this using the new precompilation technology called .NET Native. Check it out here: http://msdn.microsoft.com/en-US/vstudio/dotnetnative

Currently it is only available for Windows Store Apps. It performs single component linking. So .NET Framework libraries are statically linked into your app. Everything is compiled to native and IL assemblies are no longer deployed.

Forewarn answered 21/4, 2014 at 1:12 Comment(2)
This should be the top answer: .NET Native is a major milestone for C#/.NET, and does what the SO is asking for.Mosquito
@karim: keep in mind that the question was asked 3 years ago :)Fortis

© 2022 - 2024 — McMap. All rights reserved.