Search code examples
c#.netintermediate-language

Published application (windows form) is machine code?


I know, the question may be a usual for many, but I am confused like anything. I am reading .net with c#. I went through many articles and also msdn. My doubt is:

When I develop a C# Windows form application code in VS and run it, do the files in Project\bin\Debug\ which have the extension ".exe" are an Intermediate code or machine code? and When I Publish it, the moment i get an installer, is it a machine code or an intermediate code? because sometimes an installer requires .net installed.

Please help me understand this concept.

Thank you.


Solution

  • The compiled .exe contains MSIL (Microsoft Intermediate Language code), here's how it happens (from here):

    • Source code is converted to Common Intermediate Language, CIL's equivalent to Assembly language for a CPU.
    • CIL is then assembled into a form of so called bytecode and a .NET assembly is created.
    • Upon execution of a .NET assembly, its code is passed through the runtime's JIT compiler to generate native code. Ahead-of-time compilation may also be used, which eliminates this step, but at the cost of executable file portability.
    • The native code is executed by the computer's processor.

    When I Publish it, the moment i get an installer, is it a machine code or an intermediate code? because sometimes an installer requires .net installed.

    The .Net .exe are always MSIL code, the installer might be installing the .net framework before as a prerequisite for your application.