CorBindToRuntimeEx and ICLRRuntimeHost


CorBindToRuntimeEx and ICLRRuntimeHost

The primary unmanaged function you'll use is CorBindToRuntimeEx. This function is used to initialize the CLR into a process and is therefore the first of the hosting APIs you're likely to call. One of the return parameters from CorBindToRuntimeEx is a pointer to an interface named ICLRRuntimeHostthe initial COM interface in the hosting API. I say "initial" because ICLRRuntimeHost is the first interface you'll use when hosting the CLR. Given an interface pointer of type ICLRRuntimeHost, you gain access to all the other hosting functionality provided by the API. Figure 2-1 provides a sampling of the breadth of functionality a CLR host can access given a pointer to the ICLRRuntimeHost interface.

Figure 2-1. The CLR hosting interfaces as the gateway to the managed environment


Because of its role as the initial interface that hosts use to customize the CLR, ICLRRuntimeHost plays a part in every CLR host you'll write. As such, this interface will show up in one way or another in almost every chapter in this book. Table 2-1 provides an overview of the capabilities of ICLRRuntimeHost by briefly describing each method. The table also describes where in the book to look for more detail about each method.

Table 2-1. The Methods on ICLRRuntimeHost

Method

Description

Start

Starts the CLR running in a process. Details provided in Chapter 3.

Stop

Stops the CLR once it has been loaded into a process. Details provided in Chapter 3.

GetHostControl

Used by the CLR to discover which other interfaces the host implements. This method is described in more detail later in this chapter. See the "Hosting Manager Discovery" section.

GetCLRControl

Used by a CLR host to obtain a pointer to one of the hosting interfaces implemented by the CLR. This method is described in more detail later in this chapter. See the "Hosting Manager Discovery" section.

UnloadAppDomain

Unloads an application domain from the process. Details provided in Chapter 5.

GetCurrentAppDomainId

Returns the unique numerical identifier for the application domain in which the calling thread is currently running. I discuss this method and the overall role of application domain identifiers in Chapter 5.

ExecuteInDomain

Executes a callback function in a particular application domain.See Chapter 7 for details.

ExecuteApplication

Executes an application defined by a formal application manifest. Application manifests are a new concept in Microsoft .NET Framework 2.0. I don't cover application manifests or the ExecuteApplication method at all in this book. See the Microsoft .NET Framework SDK for details.

ExecuteInDefaultAppDomain

Executes a given method in the default application domain. This method is handy for CLR hosts that use only one application domain. This method is discussed more in Chapter 7.




    Customizing the Microsoft  .NET Framework Common Language Runtime
    Customizing the Microsoft .NET Framework Common Language Runtime
    ISBN: 735619883
    EAN: N/A
    Year: 2005
    Pages: 119

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net