Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning .NET executable into native executable

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

like image 280
lmsasu Avatar asked Jul 27 '09 12:07

lmsasu


People also ask

Can you compile C# to native code?

NET Native is a precompilation technology for building and deploying UWP apps. . NET Native is included with Visual Studio 2015 and later versions. It automatically compiles the release version of UWP apps that are written in managed code (C# or Visual Basic) to native code.

Can C# run natively on Windows?

The . NET installer will automatically set up the environment such that C# applications can be compiled and run natively on Microsoft Windows.

What are .NET executables?

Net.exe can be used to stop and start the IPv6 protocol. Restarting IPv6 reinitializes the protocol as if the computer were restarting, which may change interface numbers. Net.exe has many subcommands. The following commands are relevant to IPv6: net stop tcpip6.

Is .NET code compiled?

In . NET, programs are not compiled into executable files; they are compiled into Microsoft Intermediate Language (MSIL) files, which the CLR then executes. The MSIL (often shortened to IL) files that C# produces are identical to the IL files that other . NET languages produce; the platform is language-agnostic.


2 Answers

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!

like image 99
Richard Szalay Avatar answered Oct 11 '22 13:10

Richard Szalay


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.

like image 31
Jon Skeet Avatar answered Oct 11 '22 14:10

Jon Skeet