.NET CLR Hosting

The CLR provides an unmanaged set of functions and COM interfaces called the CLR hosting API. An application that uses the CLR hosting API are called CLR hosts. CLR Hosting is about hosting the CLR in your native process and interacting with it to optimize the CLR. Examples of applications that also are CLR hosts: SQL Server 2005, Internet Explorer, ASP.NET et.al.

CLR host applications are typically loading code dynamically. The code loaded are also usually sandboxed into a separate application domain.

Typical structure of a CLR host application.

Add-Ins are extensions to your application. Where they come from is not important. They are dynamically added to your application at run-time, and they typically run under their own security context as each application domain can have its own security context and isolation boundary.

The hosting API is defined in mscoree.idl found in the Microsoft .NET Software Development Kit.

Among the things you can adjust with the CLR hosting API:

  • Assembly Loading

The host can adjust various aspects of the CLR assembly loading process.

  • CLR Events

The host can receive various events from the CLR such as application domain unloading etc.

  • Garbage Collection

The host can force a collection and get statistics about recent collections. The host can also receive events on when collection begins and ends.

  • Memory

The host can adjust how the CLR allocates memory.

  • Threading

The host can give a custom implementation of the Thread Pool the CLR uses.

  • Synchronization

The host can provide synchronization primitives for the CLR to use.

  • I/O Completion

The host can provide a custom implementation of overlapped input/output (I/O)


Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount


Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: