to - Can you compile C#so it doesn't need the.NET Framework at runtime?

tool with (8)

It is now possible to compile C# to native code using Microsoft .NET Native:

It automatically compiles the release version of apps that are written in managed code (C# or Visual Basic) and that target the .NET Framework and Windows 10 to native code.


For users of your apps, .NET Native offers these advantages:

•Fast execution times

•Consistently speedy startup times

•Low deployment and update costs

•Optimized app memory usage

This only works with Visual Studio .NET 2015.

Is it possible to force the C# compiler to pull all the referenced calls out of the framework and pack them into dlls or even a single executable?

I like writing quick 'one-off' applications with C#, however I don't want to have to install the whole framework on the target machine once it's ready to go.

Some C# features are bound to interfaces of the .NET framework.

For example:

yield return requires the IEnumerable interface

using (x) {} requires the IDisposable interface

This dependency which unfortunately frequently breaks or is missing in the real world is a big reason why C# has not had a wider adoption. On the flip side most development does have dependencies.. look at C++ & Java for example.

I don't think we will really get away from these dependency issues anytime soon, so I recommend that if you want to use C#, that you make a wrapper for installation which checks for the .net framework version dependency you need, and if missing notify the user that they need this to run your app.

Not possible. Your "compiled" C# application is a language which the .Net CLR interprets (should have said JITed, Reads the IL, compiles to native code, and then invokes the compiled native code) at runtime.

FYI .net 2.0 is a standard install on xp SP2 and vista, so you won't be paying that much of a penalty.

You could look into mono, but this still involves running some kind of framework on your target machine.


c# .net