Turning .NET executable into native executable
Asked Answered
O

11

15

Is there any approach to convert an application developed in .NET into a native executable (sources are included)?

Installing the whole framework (up to .NET Framework 3.5 SP1) takes a lot of time - not always the computers are updated from the internet. Is it possible to call NGen in order to produce independent executables?

Thanks

Offside answered 27/7, 2009 at 12:52 Comment(1)
You can deploy the .Net framework with the installer for your application: #627025Dourine
N
12

It's not available yet, but the Mono project team are working on an Ahead of Time compiler that will do what you are looking for. The intention is for Mono to work on the iPhone (like Unity) but it should work for all platforms.

Edit: It does support Mono x86, but I'm not sure if they have included the feature that packs in dependent classes yet (though from an interview I heard, it's planned)

Edit 2: Including dependencies is currently supported, thanks Dykam!

Nonintervention answered 27/7, 2009 at 12:55 Comment(3)
The aot does work for a time already. I don't get what you mean with dependent classes. If you mean including referenced dll's, that is surely supported, as the bcl has to be compiled into the resulting executable too. Note that reflection and related is not available.Rapids
Thanks Dykam. It may have been that optimisation of that process (ie. only including necessary classes and/or methods) that was mentioned as not being ready.Nonintervention
FYI, I believe the interview I mentioned was part of this episode of Hanselminutes: hanselminutes.com/default.aspx?showID=186Nonintervention
F
9

No, NGen'd code still needs the framework - it only pre-JITs the code in your own assemblies. It also requires the framework for the CLR itself.

I believe Mono has a static compiler which they're planning on using for the iPhone. I don't know whether that will work on Windows as well though.

There used to be a product called Thinstall which some people used for this. It's now called ThinApp - basically it's application virtualisation. It's commercial, but you may well be able to get hold of a trial version.

Personally I'd be somewhat concerned about any such product - when it comes to deployment, veering away from the mainstream way of doing things sounds like a recipe for lots of support calls. There's just an awful lot to go wrong. I'm not saying it doesn't work, just that I'd be wary.

Have you looked at the .NET 3.5 (SP1) Client Profile? That may help to reduce your installation requirements a little.

Facesaving answered 27/7, 2009 at 12:54 Comment(1)
Thinstall was brought by VMware and is now called "ThinApp" - vmware.com/products/thinappOg
A
6

With .net 3.5 SP1 it is possible to install a smaller subset of the .net framework. Take a look at this screenshot: Visual Studio Project properties
(source: windowsclient.net)

Applause answered 27/7, 2009 at 13:2 Comment(0)
T
3

You can use NGen to make your application a native executable, but it will still be dependent upon the .Net framework.

Tanagra answered 27/7, 2009 at 12:55 Comment(6)
I think we cannot call it "native executable" while "still being dependent" upon the .NET framework.Offside
It is a native executable in that it contains native code, but it still has dependencies on external libraries.Nonintervention
Well, I suppose that the external libraries still require .NET Framework runtime installed? Or maybe the "native executable" term is not the most appropriate?Offside
Native executable is the correct term for this according to Microsoft. It is native code rather than MSIL, but still depends on the runtime libraries.Strawn
NGen'd assemblies are native code, but still rely on the runtime for garbage collection (and possibly other things).Nonintervention
I should have said "native image" instead of "native executable", but that's irrelevant to the question here. The asker wanted to know if he could create a .Net executable that wasn't dependent upon the .Net framework.Tanagra
O
3

NGen compiles the exes to native exes, so they do not need to be JIT compiled as they are run. They are still dependant on the framework though.

There are a few commercial companies that do provide products for compiling .net assemblies into standalone exes. Xenocode and vmware's Thinapp. Neither are cheap though.

Og answered 27/7, 2009 at 12:59 Comment(0)
C
1

Some Obfuscators do this, you would have to do it beforehand though (before you ship it to your users). An example is remotesoft's Salamander.

Cravens answered 27/7, 2009 at 13:0 Comment(0)
S
1

You will only need to install the version of .NET that you are targeting e.g. .NET1.1 or .NET2.0

Edit: If you need to target the 3.5 version you will need to install both 2.0 and 3.5

ILMerge (Free) can combine several assemblies into one, but I don't think that it works with the core runtimes.

In short I think that if you want to run .NET programs you will need the .NET Framework installed.

Strawn answered 27/7, 2009 at 13:2 Comment(1)
Yes, I think you are right 1.1 and 2.0 are separate but 3.5 added extra libraries to 2.0Strawn
V
1

There is a commercial product that claims to do that here:

http://www.xenocode.com/Obfuscator/

"Deploy .NET applications securely, with no .NET Framework install"

No idea what the drawbacks to this would be though

Valerio answered 27/11, 2009 at 21:20 Comment(1)
Probably! I didn't want to create a login just to find out what the price was, so it must be alot.Valerio
F
1

ThinApp (formerly Thinstall) from vmware. Used to be very expensive, though.

http://www.vmware.com/products/thinapp/

Fiore answered 16/3, 2010 at 15:30 Comment(0)
E
1

The only product we founded to solve the problem in 2007 was Xenocode Postbuild. From that time we use this product successfully, we use also its pretty good virtualization features.

The only problem is that the version we purchased don't support the Windows 7 (where you don't need to install .net framework to run your program compiled with version < 4.0). So I wrote to Xenocode. They answered

In order to get support for Win 7 you should upgrade to the newest version of Postbuild (now called .NET Obfuscator). Win 7 is not a supported platform for Postbuild 2007.

Eiten answered 17/5, 2010 at 14:21 Comment(0)
E
1

Why not Ngen.exe? http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.80).aspx

It converts .Net Programs into Native Programs also and you already have it if you have the .Net Framework

Entreat answered 13/12, 2012 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.