Managed Code Execution
To load and execute an assembly, the common language runtime has to be hosted within a process first. The .NET Framework provides APIs to let an application host the common language runtime. Some examples of such host applications are ASP.NET, SQL Server .NET, and so on.
An EXE-based assembly contains a small piece of bootstrapping code that points to a function exported by the .NET runtime, named CorExeMain. When such an assembly is executed, the OS creates a process and executes CorExeMain. This function in turn loads the common language runtime into the process and transfers control to it.
Using a standard PE file mechanism to bootstrap the common language runtime is a clever technique on the part of Microsoft. It ensures ...
Get .NET Programming: A Practical Guide Using C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.