tags:

views:

1328

answers:

7

Can this be done? Is it possible to force it to pull all the of the referenced calls out of the framework and pack them into dlls or even a single executable? I like writing quick one off apps with C# however I don't want to have to install the whole framework on the target machine once its ready to go.

Thanks! sweeney

+4  A: 

Look at mkbundle using Mono.

dpp
cool i think im gonna go this route - thanks!
sweeney
I'm sure there was a tool for Windows that I used to do that, a *long* time ago. Maybe ILMerge?
configurator
is there a windows installer for the mono ide? i've found the source but i'm having a hard time locate a binary. i supposed to could just compile it but it gives me more chances to screw something up...
sweeney
An installer is available at http://www.go-mono.com/mono-downloads/download.html (click the windows icon and the links will appear)
dpp
that link does not seem to include the IDE, just the rest of the tools and libs, unless i'm mistaken. It seems as though you still need to DL the IDE source and compile and run in from inside of cygwin, unfortunately.
sweeney
+1  A: 

Not possible. Your "compiled" C# application is a language which the .Net CLR interprets 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.

Spence
+4  A: 

Take a look at the .NET client profile. This will allow you to package a minimum install on the client machine.. which will later be updated by windows update to the full framework.

This depends, of course, on your app only using libraries that are contained in the client profile ...

Some info here: http://blogs.windowsclient.net/trickster92/archive/2008/05/21/introducing-the-net-framework-client-profile.aspx

markt
+3  A: 

It's said it is possible, using 3rd-party tools such as http://www.remotesoft.com/linker/

ChrisW
For such a horrendously ugly website that looks like an amazing product especially if you're worried about source theft since obfuscation is almost trivial to a real cracker.
Chris Marisic
+9  A: 

You ask a loaded question. C# is merely a language and does not require the .NET Framework. The process of compiling it requires a compiler, which may or may not itself take a dependency on the .NET Framework (Microsoft's C# compiler does not -- it is written in native code). Your program will need to reference some assembly where types, classes, and methods can be found for your use. You can remove system.dll and mscorlib.dll from your references list and reference your own assemblies. So you can avoid dependencies on the .NET Framework if you really work at it. But in the end, unless you have a C# compiler that compiles programs to native code you still have a dependency on the CLR.

That's a very technical way of saying... almost nothing. But it answers your question. :) More practically useful however is how to get your C# programs to run with a minimum of dependencies. mkbundle from mono will actually let you compile it all into an .exe with virtually no dependencies.

But if you want to stick with the Microsoft .NET Framework, you can achieve a much lighter footprint and faster install of the dependencies you commonly need by using the Client profile of .NET 3.5 SP1. You can read about it here: http://msdn.microsoft.com/en-us/library/cc656912.aspx

Andrew Arnott
very informative - thank you
sweeney
I'm trying to do this same thing with Visual Studio, and I'm being told it's impossible.
rar
What is "this same thing"? I talk about several options here.
Andrew Arnott
A: 

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

Rauhotz
+1  A: 

Can I have a shower without getting wet?

depends on whether you're refering to the shower object or method
kjack