• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

run c# programs without .net installed

supersloth

Senior member
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
 
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.
 
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.
 
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.

 
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.
 
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.
 
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.
 
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
 
Back
Top