Enables unmanaged hosts to load the common language runtime (CLR) into a process. The CorBindToRuntime and CorBindToRuntimeEx functions perform the same operation, but the CorBindToRuntimeEx function allows you to set flags to specify the behavior of the CLR.
See Hosting the Common Language Runtime for a complete description of the scenarios in which CorBindToRuntimeEx is used.
This function takes a set of parameters that allow a host to do the following:
Specify the version of the runtime that will be loaded.
Indicate whether the server or workstation build should be loaded.
Control whether concurrent garbage collection or non-concurrent garbage collection is done.
Concurrent garbage collection is not supported in applications running the WOW64 x86 emulator on 64-bit systems that implement the Intel Itanium architecture (formerly called IA-64). For more information about using WOW64 on 64-bit Windows systems, see Running 32-bit Applications.
Control whether assemblies are loaded as domain-neutral.
Obtain an interface pointer to an ICorRuntimeHost that can be used to set additional options for configuring an instance of the CLR before it is started.
HRESULT CorBindToRuntimeEx ( [in] LPWSTR pwszVersion, [in] LPWSTR pwszBuildFlavor, [in] DWORD startupFlags, [in] REFCLSID rclsid, [in] REFIID riid, [out] LPVOID* ppv );
If pwszVersion specifies a runtime version that does not exist, CorBindToRuntimeEx returns an HRESULT value of CLR_E_SHIM_RUNTIMELOAD.
Execution Context and Flow of Windows Identity
In version 1 of the CLR, the WindowsIdentity object does not flow across asynchronous points such as new threads, thread pools, or timer callbacks. In version 2.0 of the CLR, an ExecutionContext object wraps some information about the currently executing thread and flows it across any asynchronous point, but not across application domain boundaries. Similarly, the WindowsIdentity object also flows across any asynchronous point. Therefore, the current impersonation on the thread, if any, flows too.
You can alter the flow in two ways:
By changing the process default mode to the version 1 compatibility mode, where the WindowsIdentity object does not flow across any asynchronous point, regardless of the ExecutionContext settings on the current thread. How you change the default mode depends on whether you use a managed executable or an unmanaged hosting interface to load the CLR:
For managed executables, you must set the enabled attribute of the <legacyImpersonationPolicy> element to true.
For unmanaged hosting interfaces, set the STARTUP_LEGACY_IMPERSONATION flag in the startupFlags parameter when calling the CorBindToRuntimeEx function.
The version 1 compatibility mode applies to the entire process and to all the application domains in the process.
Platforms: See .NET Framework System Requirements.
.NET Framework Versions: 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0