C# Compiling to standalone exe

This is a discussion on C# Compiling to standalone exe within the C# Programming forums, part of the General Programming Boards category; Hi All, Im just after some general imformation and tips about c#. Im just about to write a simple windows ...

  1. #1
    Registered User RocketMan's Avatar
    Join Date
    Dec 2007
    Posts
    28

    C# Compiling to standalone exe

    Hi All,

    Im just after some general imformation and tips about c#.

    Im just about to write a simple windows app, but want it versitile so it can run on windows 2000, xp, vista and the latest windows just comming out. So my very technical question is, can i write a c# app and generate an exe that can work on all of these platforms, and easy for the customer to deploy without downloading patches from the microsoft site? I seem to remember people saying its hard to create a true exe in c#?

    Would i be better creating it in borland c++ or something. What do you recommend?

    Regards,

    Rocketman.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    I believe it could. C# is usually (always?) translated in CIL which is independent from CPU or platform. So yeah, you would be able.
    The downside is that the computer would have to have the .NET framework installed

    You could turn a C# in machine code directly as C/C++ compilers do. But the recommended, default, fun, happy, we-all-do-it option is to go with the above

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Assuming the users of your application have the appropriate framework installed that your application was targeted to, it will run fine. This is a major design goal of .NET. Also newer frameworks that come out also support the older framework, that being said when windows 7 is released, your .NET 2.0 applications should still run as expected.

  4. #4
    Registered User RocketMan's Avatar
    Join Date
    Dec 2007
    Posts
    28
    Hi,

    Thanks for your replies.

    The only reason I ask is because one of my friends said its best to write in C++ MFC because this enviroment is able to create a standalone exe. However I have heard writting MFC from the word go can be very hard to learn? So your advice would be to go with C#?

    Cheers.

    Rocketman.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    You can create a true EXE in C# but you lose all the benefits of .NET and assemblies and the EXEs are far bigger than the assemblies.

    When you compile C# to an executable it will bring in all of the .NET framework that is being used. Since most C# programs use only a portion of the framework this really bloats the code. Even though you may only be using 5 to 10 percent of one portion of .NET it will bring in 100% of it. It may also run slower or faster depending on how the compiler treats the MSIL and brings it down to native code. One thing is for sure though you can kiss your 250kb apps goodbye b/c compiling to a native EXE can bloat the code by a factor of 10 or more.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. how to run an exe command in c++ and get back the results?
    By mitilkhatoon in forum C++ Programming
    Replies: 5
    Last Post: 09-21-2006, 07:00 PM
  3. Close another exe from another exe??
    By Tony in forum Windows Programming
    Replies: 1
    Last Post: 06-12-2002, 08:19 AM
  4. insert another exe into exe
    By lliero in forum C Programming
    Replies: 8
    Last Post: 04-12-2002, 01:22 PM
  5. adding bytes to EXE to call another EXE
    By lliero in forum C Programming
    Replies: 2
    Last Post: 03-30-2002, 07:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21