I have one major question and two minor questions that are all related. Firstly, does ngen.exe actually compile to native exes that you can distribute? There is very little known about ngen.exe. Secondly, is there actually a way to compile .net to native x86 code even if they still depend on the .net framework. Lastly, with mono, can you compile to native code, by just 'chucking' your project from VS to mono?
Asked
Active
Viewed 1,113 times
2
-
I can see where this is heading and the answer is "no". Ngen must be run on the user's machine, you cannot ship the .ni.dll files. And you still need the original assemblies, they contain the metadata that the jitter requires. – Hans Passant Jun 25 '13 at 13:36
-
Thank you, an honest answer. But is there a way to compile to native code? – user2514562 Jun 25 '13 at 22:34
1 Answers
0
Short answer: yes. When you start a .NET application that is not NGEN'ed, when you execute a method for the first time, it's compiled to native code. The .NET virtual machine doesn't execute MSIL, it only executes the native code. What NGEN does is that it does all of this work up front. See http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.80).aspx for more information.

Pieter van Ginkel
- 29,160
- 8
- 71
- 111
-
1There is infrastructure that manages a lot, like e.g. garbage collection. That's what you'd call a virtual machine. – Pieter van Ginkel Jun 25 '13 at 09:34
-
Or you can just see what [Brad Abrams](http://www.businessinsider.com/guy-in-charge-of-microsoft-silverlight-goes-to-google-2010-5) thinks, http://stackoverflow.com/questions/1564348/is-the-clr-a-virtual-machine, which is 'the CLR and JVM are in the same class whether you call that class of software “virtual machines” or “execution engines” depends on your perspective.' – Motomotes Mar 12 '14 at 19:21