Partager via


Transitioning to Managed Hosting Code 

After loading and initializing the common language runtime, the host must make the transition from unmanaged to managed code in order to execute managed hosting code and user code. In earlier versions of the .NET Framework, managed hosting code is usually run in the default application domain, but the .NET Framework version 2.0 provides a base class, AppDomainManager, for implementing managed hosting code that is automatically loaded into every application domain created in the process.

The host sets its application domain manager, loads it into the default application domain, and obtains a pointer to its interface by calling IHostControl::SetAppDomainManager. The interface that is returned can be used to execute managed code. The designer of the host defines this interface, and thus is in a position to determine how much code is executed in the unmanaged host and how much is executed in the application domain manager.

NoteNote

In the .NET Framework versions 1.0 and 1.1, the host obtains an interface pointer to the default application domain by calling ICorRuntimeHost::GetDefaultDomain. The call returns an _AppDomain interface pointer to the instance of the AppDomain class that represents the default application domain. The host then uses the Load method of the AppDomain class to load the managed portion of the host into the default domain.

See Also

Reference

IHostControl
AppDomain
AppDomainManager

Concepts

Creating and Configuring Application Domains

Other Resources

Hosting the Common Language Runtime