I would like to distribute my .NET programs without the .NET framework. Is it possible to compile a .NET program to machine code?
I don't think that it is possible. You can make a prejitted assembly but you still need the framework.
Remotesoft has one: Salamander .NET Linker
I don't have any experience with it though.
Yes, you can precompile using Ngen.exe, however this does not remove the CLR dependence.
You must still ship the IL assemblies as well, the only benefit of Ngen is that your application can start without invoking the JIT, so you get a real fast startup time.
According to CLR Via C#:
Also, assemblies precompiled using Ngen are usually slower than JIT'ed assemblies because the JIT compiler can optimize to the targets machine (32-bit? 64-bit? Special registers? etc), while NGEN will just produce a baseline compilation.
EDIT:
There is some debate on the above info from CLR Via C#, as some say that you are required to run Ngen on the target machine only as part of the install process.
I think you should not: That's the task of the JIT compiler.
However, you could use ClickOnce or Windows Installer to deploy it so that the missing framework isn't such a big problem: you could tell the installer to download the Framework and install it.
Another (expensive and proprietary, licenses start at $1599) product that can do this is Xenocode Postbuild. Haven't used it myself though, with it costing about the gross national product of a small African country and all...
I'd always thought it would be cool to compile c# to machine code directly without the CLR dependency though....
Is it possible to compile .NET IL code to machine code?
Yes, but the .NET Framework does it for you at runtime (default) or at install time (ngen). Among other reasons, this IL -> machine code is done separately on each install machine so it can be optimized for that particular machine.
I would like to distribute my .NET programs without the .NET framework. Is it possible to compile a .NET program to machine code?
No, for all intents and purposes you cannot do this. The 3rd party workarounds may work in some scenarios, but by then I wouldn't really consider it "managed code" or ".NET" anymore.
Look at MONO project: mono command with --aot option. http://www.mono-project.com/AOT