run c# programs without .net installed

supersloth

Senior member
Apr 19, 2005
270
0
0
hey, i just started trying to learn c# this week, and i was wondering if anyone knew of a way to compile a c# program in a way that it would run on a computer without the .net framework installed. i've made this server client program that my friends and i are using as a instant messanger/ file transfer program for fun, but we want to beable to use it on any computer reguardless if it has .net installed or not. would visual basic or visual c++ allow me to do this?

supersloth
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Sorry, I'm pretty sure that's impossible. The .NET framework is a virtual machine. *Maybe* native image generator (ngen.exe) will do it, but I don't know if that means make it in to a native EXE.
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
Sorry, I think you will have to rewrite that in C or C++. The syntax is similar, but the networking functions are different... shouldn't be too hard.
 

supersloth

Senior member
Apr 19, 2005
270
0
0
well, the whole reason i did it in c# was because its really easy to make socket programs, so is java for that matter. so if i have to write it in c or c++, whats a good compiler for windows, i've only used g++ in linux and really don't know where to begin.

 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
You can download Visual C++, I think they call it the express edition or something like that, from MS for free. That's pretty much the standard C++ compiler for windows.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
yeah, c# programs have to use the common language runtime, so you can't run them without .net. i would also recommend the c++ compiler that comes with visual studio (visual c++). g++ is also okay, but if you already have visual studio, having the use of the IDE is nice.

edit: xtknight mentioned ngen.exe and that does create a native executable, but all that does is avoid the just-in-time compilation that normally happens when you run a .net executable. the resulting "native executable" is still considered "managed" and still needs the CLR.
 

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
The .net compiler creates virtual machine code that needs to run on the .net virtual machine, just like the java compiler creates virtual machine code that needs to run on a java virtual machine.

AFIAK, there is no compiler for either that that will compile your program directly into machine code, so it will run without the virtual machine.
 

supersloth

Senior member
Apr 19, 2005
270
0
0
yea, i was researching ngen.exe and it won't help, i guess i'll just have to do it all in c++ or c, which will be good practice for me over the break. i orginally did it in java because they have good solutions for managing threads, but since i'm not having to keep up with any global variables in my program, it shouldn't be a issue. thanks for the help!

supersloth