.Net Framework, compiled or translated? RRS feed

  • Question

  • Sorry but I have this basic question, is about plataform .NET Framework, I'd like to know if the final result is a machine compiled code compatible with .NET FW or is a .NET FW code to be translated in runtime as with Java?.

    Too, I'd like to know about the same but with C# and Basic. We know that pure C++ code is optimized machine code, but how works C# or Basic about this?.

    Monday, October 31, 2005 11:02 AM


All replies

  • Hi,

    The .NET compilers convert the code to MSIL - Microsoft Intermediate Language which is something similar to Java bytecodes. This is then converted to machine language by the JIT Compiler at runtime.
    Read more here.

    You can however choose to create a native image using tools provided by the .NET SDK:

    Monday, October 31, 2005 11:15 AM
  • Are you talking about 'ilasm.exe' and 'ildasm.exe'?.

    Then we must suppose that C# and Basic always generate MSIL, not?.

    Monday, October 31, 2005 12:49 PM
  • The tool is ngen.exe. I'll add the following distinction to the answer: You can generate binary images during deployment for your assemblies, you can't distribute naitve images.

    Diego Gonzalez
    Lagash Systems SA
    C# MVP
    Monday, October 31, 2005 2:44 PM
  • I don't have very clear how 'ngen' works, what image it generate, or when I type 'ngen /show' what is that list, because I don't have generated nothing yet. Where it put the native images?, description says that it 'install the image in the local cache' (??).

    A bit confusing.
    Tuesday, November 1, 2005 9:23 AM
  • NGen takes a MSIL assembly and generates the native image for it. The generated native code uses machine specific instructions for optimization reasons, so you have to generate the MSIL assembly first and use the NGen on the deployment computers.
    The generated native image is found in the Global Assembly Cache. When you try to load the assembly, the CLR loads the native image from the GAC instead of loading the MSIL assembly.
    Tuesday, November 1, 2005 11:51 AM
  • Hi,

    Check out the following article for more in-depth info:

    Tuesday, November 1, 2005 11:51 AM
  • I see, but what is the "Global Assembly Cache"?, it is a directory in system HD?.
    Wednesday, November 9, 2005 11:00 AM
  • Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.
    For more infromation about the GAC, see the following link:
    Wednesday, November 9, 2005 6:24 PM