Sachin Singh

Sachin Singh

  • 7
  • 55.8k
  • 81.8k

IL Code, CLR and .NET evolution (.NET 6)

Feb 16 2022 4:53 PM

As far as I know, codes written in any .NET language can not be executed without CLR.

Please take this code

public static void Main(string[] args)
{
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddControllersWithViews();
    using var app = builder.Build();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapDefaultControllerRoute();
    });
    app.Run();
}

The documentation says CreateBuilder adds an IServer instance by calling the UseIIS method to boot the CoreCLR and host the app inside of the IIS worker process (w3wp.exe or iisexpress.exe).

I can not understand a bit how the CLR can be started from the Main() method. Then Who is converting this Main() IL to machine code?

Or am I missing something?


Answers (1)