ICorRuntimeHost provides the following capabilities:
Get and set global events and configure parameters such as GC heap allocation. Configuration is done through the ICorConfiguration interface.
Create Application Domains in which to run code. The methods on ICorRuntimeHost that are used to create domains return interface pointers to instances of System.AppDomain. Hosts call methods on this interface through COM interop to load assemblies into the domain, etc …
Any configuration of the runtime must be done before it is started. Subsequent configuration requests will be ignored and an error returned.
ICorRuntimeHost and associated interfaces are defined in mscoree.idl:
typedef void* HCORENUM; interface ICorRuntimeHost : IUnknown { HRESULT GetConfiguration([out] ICorConfiguration** pConfiguration); HRESULT Start(); HRESULT Stop(); HRESULT CreateDomain([in] LPWSTR pwzFriendlyName, // Optional [in] IUnknown* pIdentityArray, // Optional [in] IUnknown* pPolicyArray, // Optional [in] LPWSTR pwzAppRelativeSearchPath, // Optional [in] LPWSTR pwzGlobalSearchPath, // Optional [in] bool bShadowCopyFiles, // Optional [in] long snapshotID, // Optional [out] void ** pAppDomain); HRESULT GetDefaultDomain([out] IUnknown** pAppDomain); HRESULT EnumDomains([out] HCORENUM *hEnum); HRESULT NextDomain([in] HCORENUM hEnum, [out] void** pAppDomain); HRESULT ResetDomainEnum([in] HCORENUM hEnum); // These routines are being depricated HRESULT CreateFiberInfo(); HRESULT DeleteFiber(); HRESULT SwitchFiberIn( [in] DWORD pFiberCookie); // [in] Cookie that indicates the fiber to use. HRESULT SwitchFiberOut( [out] DWORD *pFiberCookie); // [out] Cookie that indicates the fiber being switched out. HRESULT MapFile( [in] ULONG hFile, // [in] HANDLE for file [out] HMODULE* hMapAddress); // [out] HINSTANCE for mapped file HRESULT GetCompileInfo( [out] ICorCompileInfo **ppCompileInfo); }
Returns an interface (ICorConfiguration) that can be used to configure the runtime. All configuration must be done before calling ICorRuntimeHost::Start. ICorConfiguration currently has just one method. This interface will be expanded with additional configuration methods as needed.
Parameters:
Name | Description |
---|---|
pConfiguration | [out] A pointer to an ICorConfiguration interface |
Starts the runtime. This is equivalent to CoInitializeCor();
Terminates the runtime. This is equivalent to CoUninitializeCor();
Creates an AppDomain. The caller receives an interface pointer to an AppDomain object that can be used to further control the domain.
Parameters:
Name | Description |
---|---|
pwzFriendlyName | [in] An optional parameter used to give a friendly name to the domain. This friendly name can be displayed in user interfaces to identify the domain (like in the debugger). |
pIdentityArray | [in] An optional array of pointers to IIdentity objects that represent evidence that gets mapped through security policy to establish a "top of stack" permission set. |
pPolicyArray | [in] An optional array of context policies to be added to the basic policies of the domain. Note: This is not implemented in the prerelease. |
pwzAppRelativeSearchPath | [in] A semi-colon separated list of directories to search for privately referenced assemblies. These directories must be contained within the application directory. If not supplied, the default search path is the current app directory. |
pwzGlobalSearchPath | [in] A semi-colon separated list of directories to search for global, strongly named assemblies. |
bShadowCopyFiles | [in] This flag tells the runtime to make a shadow copy of a module, and load the copy instead of the original. The original is left unlocked and can be overwritten. The default is false. |
SnapshotID | [in] This property relates to the one above. When we make a copy of a file to load, we associate a snapshotID with it. If the next request to copy the file contains the same snapshotID, we don't bother copying it again. The default is 0xffff. This default tells us to "always copy". |
pAppDomain | [out] A interface pointer to an instance of System.AppDomain that can be used to further control the domain. See the class description for AppDomain below. |
Returns an interface pointer to the default domain for the process.
Parameters:
Name | Description |
---|---|
pAppDomain | [out] A pointer to an instance of System.AppDomain representing the default domain for this process. See System.AppDomain. |
Returns an enumerator that a host can use to enumerate the domains in the process.
Parameters:
Name | Description |
---|---|
hEnum | [out] The enumerator |
Returns the next domain in the enumeration. This method returns S_FALSE when there are no more domains in the enumeration.
Parameters:
Name | Description |
---|---|
hEnum | [in] The enumerator |
PAppDomain | [out] An interface pointer to the instance of System.AppDomain representing the next domain in the enumerator. |
Resets the enumerator back to the beginning of the list.
Parameters:
Name | Description |
---|---|
hEnum | [in] The enumerator to reset. |