Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Loading the Common Language Runtime into a Process

Before any managed code can be executed, the host must load and initialize the common language runtime (CLR). All hosts start with an unmanaged stub because the runtime is not yet running in the process. The .NET Framework provides a set of unmanaged APIs called the hosting APIs that the host can use to start the runtime. For more information, see Hosting Interfaces.


Hosting methods provided by versions of the .NET Framework before the .NET Framework version 4 are deprecated. We recommend that you use the interfaces introduced by the .NET Framework 4 and discussed in this topic.

A host can load the CLR into a process by using one of the following procedures:

The prototype for all these interfaces is located in the Metahost.h file, which is located in the Include directory of the Windows Software Development Kit (SDK). Hosts can use both the ICLRRuntimeInfo and ICLRRuntimeHost interfaces to control which version of the runtime to load and to control the behavior of basic functions such as garbage collection and assembly loading.

Use the ICLRRuntimeHost interface to perform the following actions:

  • Start the runtime by calling the ICLRRuntimeHost::Start method.

  • Execute managed code.

  • Obtain a pointer to the ICLRControl interface (which provides access to the managers that are implemented by the common language runtime), and register a host control object that implements the IHostControl interface. The common language runtime calls the IHostControl interface to determine which managers the host implements.

© 2018 Microsoft