Thread: Does C# compile to an exe?

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    204

    Does C# compile to an exe?

    I'm a noob to C#. Does C# compile to an executable .exe file the way that C++ does? I understand that it compiles to byte code like Java, but I wasn't sure if I had to type something like "ms-csharp my_prog.class" in order to run it.

    Also, is it possible to compile C# to a .DLL file in a way similar to C++?
    Last edited by thetinman; 11-12-2008 at 09:39 AM. Reason: added dll Q

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Not like C++ does, but to an executable that the CLR can understand. MIL, microsoft intermediate language. Each method call is Jittered (JIT) or just in time compiled before it executes. So in order for a computer to run this it will need the .Net framework installed on the machine, luckily this is most modern microsoft machines. This is similar to the java runtime in a sense.

    To a user though, as long as they have the framework installed, the executable is transparent to what language it was written in and behaves like a normal program.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    204
    Is the code compiled into an executable that I can click on to run?

  4. #4
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Yes. But the executable code contained in it does not contain the instructions that do what the C# code does, not in the format the specified cpu architecture can understand at least. The code stored in the executable is run by the CLR, but yes, it does compile to an executable.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  5. #5
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    C# code compiles to a .NET assembly.
    This can be an executable for use within the .NET CLR, a dll for use with the CLR, or a type library for inclusion in other .NET assemblies.

    If an executable, it will have a .exe extension as standard.

  6. #6
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Cool

    Quote Originally Posted by jwenting View Post
    C# code compiles to a .NET assembly.
    This can be an executable for use within the .NET CLR, a dll for use with the CLR, or a type library for inclusion in other .NET assemblies.

    If an executable, it will have a .exe extension as standard.
    just a question

    it's possible to compile anexe with c# so excute within framework installed ?

    somewone have an explication please

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    No, it is not possible to compile C# so that it can run without the framework installed. C# only half compiles, the final compilation is done by the framework at runtime. This is both a good feature and a security risk. It is good because in theory as new processor technologies become available and the framework is updated, your existing applications will take advantage of these if possible. It is a security risk because anyone that makes half an effort can extract your source code from the executable.

  8. #8
    Registered User
    Join Date
    Aug 2008
    Posts
    188
    Quote Originally Posted by abachler View Post
    No, it is not possible to compile C# so that it can run without the framework installed. C# only half compiles, the final compilation is done by the framework at runtime. This is both a good feature and a security risk. It is good because in theory as new processor technologies become available and the framework is updated, your existing applications will take advantage of these if possible. It is a security risk because anyone that makes half an effort can extract your source code from the executable.
    both of which can be resolved with 3rd party tools.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM
  2. No compile time errors, exe crashes.
    By RealityFusion in forum C++ Programming
    Replies: 13
    Last Post: 09-06-2005, 12:34 PM
  3. open scene graph compile issues
    By ichijoji in forum Game Programming
    Replies: 1
    Last Post: 08-04-2005, 12:31 PM
  4. compile program?
    By Goosie in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2005, 02:26 PM
  5. dvv-cpp not able to compile?
    By Rune Hunter in forum C++ Programming
    Replies: 12
    Last Post: 10-23-2004, 06:36 PM