views:

184

answers:

3

AFAIK, ngen turns MSIL into native code (also reffered to as pre-JIT), however I never payed too much attention at it's startup performance impact. Ngen'd applications still require the .NET base class libraries (the runtime).

Since the base class libraries have everything our .NET assemblies need (correct?) would it be possible to ship the framework's DLLs with my ngen'd application so that it does not require the runtime to be installed? (e.g., the scenario for most Windows XP machines)

Oh, and please don't bother mentioning Remotesoft's Salamander Linker or Xenocode's Postbuild. They are not for my (and many's) current budget (and they seem to simply bundle the framework in a virtualized enviroinment, which means big download sizes and slow startup times I believe)

EDIT:
I know now, ngen doesn't do what I thought it did.
But is it possible to bundle the .NET files with an application, without using a VM?

+1  A: 

See http://stackoverflow.com/questions/45702/is-there-some-way-to-compile-a-net-application-to-native-code - the consensus looks to be that it's not possible.

Axarydax
Yes, I know it's not possible to turn a .NET assembly into native code (i.e., translate .NET to native), but what I want is to simply bundle the runtime DLLs that I actually use (since most of them are pretty light-weight, such as system.dll being little more than 1 MB) and run my application with them, with the nice possibility of running more than one application and/or more than one version without re-packaging the whole thing (what both Salamander/Postbuild do). My main concern is to shave off size from the framework and be able to run my code without the framework present in the machine.
Camilo Martin
+2  A: 

That's not how Ngen works. It only bypasses the JIT compilation step. The resulting .ni.dll file only contains machine code, not the metadata of the assembly. You need to keep the original assembly available for that. And the CLR and the .NET framework assemblies must be available on the target machine, requiring you to install .NET.

Hans Passant
I'm sorry then, I've never used ngen myself. But Xenocode seems to run by embedding a framework subset within a virtual filesystem, and I believe it's not a full virtual OS like XP mode on Win 7, so there may be a way to leave out the absurdly long .NET setup and some redundant assemblies (to my application) in such a project. Also, network connectivity or that bloated target-all-processors 200+ MB redist wouldn't be necessary.
Camilo Martin
You can target the .NET Client Framework, it is only 26 MB. Re-inventing a linker is only technically feasible. The high license fees they charge for them is commensurate with the effort and the burden of keeping it compatible with framework releases. If this is an obstacle then targeting .NET is probably the wrong approach.
Hans Passant
Thanks for your comment, since the Client Framework is a good idea, and it seems Microsoft does not care about how developers should deal with Legacy OSes + different versions of the framework =( If I had to bloat my software by 26 MB witout having the install-hell of the framework, it would be beautiful already =(
Camilo Martin
+4  A: 

You cannot do this. Many essential components such as the garbage collector are part of the CLR (which is part of the framework runtime), so in order to successfully execute your application you need the framework installed.

Darin Dimitrov
I understand, and I would really give up on the idea of being able to bypass the whole .NET setup if products such as Xenocode didn't exist. Kinda stubborn of me I know =P
Camilo Martin
@Camilo Martin, 90% of Windows PCs already have .NET installed and 65% have .NET 3.5 SP1 installed (http://www.hanselman.com/blog/HowManyPCsInTheWorldHaveTheNETFrameworkInstalled.aspx). So why bother?
Darin Dimitrov
Well I don't know where he got those numbers, since I believe less than 90% of *worldwide* users have .NET 2.0. In any case, I just want my software to work even without .NET (or say, without .NET 3.5 SP1) installed. Those stats could be from the logs of a small blog visited by tech-aware people. Not to mention that, in my experience, most corporate/commerce/industry PCs are not allowed to install software, and many of them run on legacy OSes =(
Camilo Martin
Besides, IE6 is minority already and web developers bother about it. That's the same bothering I have for .NET.
Camilo Martin