More book updates for Customizing the CLR

I’ve recently been made aware of two more updates I need to provide for my book on Customizing the .Net Framework CLR. As always, I apologize for any inconvenience these discrepancies may have caused.

Chapter 2, Page 7. The table which lists the methods on ICLRRuntimeHost indicates that more information about ExecuteInDomain is available in Chapter 7. I had not intended to cover this method at all in the book, but the forward reference still exists. If you’d like information on ExecuteInDomain I’d be happy to provide you with a sample.

Chapter 5, Page 90.   The SetAppDomainManagerType method on ICLRControl is used to inform the CLR of the assembly and type that implements your domain manager. The code sample on page 90 calls SetAppDomainManagerType after the CLR has been initialized by a call to ICLRRuntimeHost::Start:

int main(int argc, wchar_t* argv[])

{

   // Initialize the CLR using CorBindToRuntimeEx. This gets us

   // the ICLRRuntimeHost pointer we’ll need to call Start.

   ICLRRuntimeHost *pCLR = NULL;

    HRESULT hr = CorBindToRuntimeEx(

      L"v2.0.31113",

   L"wks",

      STARTUP_CONCURRENT_GC,

      CLSID_CLRRuntimeHost,

      IID_ICLRRuntimeHost,

      (PVOID*) &pCLR);

    // Start the CLR

   hr = pCLR->Start();

   // Get a pointer to the ICLRControl interface

ICLRControl *pCLRControl = NULL;

hr = pCLR->GetCLRControl(&pCLRControl);

// Call SetAppDomainManagerType to associate our domain manager with

// the process

pCLRControl->SetAppDomainManagerType(

L”BoatRaceHostRuntime, Version=1.0.0.0, PublicKeyToken=5cf360b40180107c, culture=neutral”,

      L"BoatRaceHostRuntime.BoatRaceDomainManager"

);

// rest of main() omitted…

}

This is incorrect. SetAppDomainManagerType must be called before ICLRRuntimeHost::Start. Here’ the corrected code sample:

int main(int argc, wchar_t* argv[])

{

   // Initialize the CLR using CorBindToRuntimeEx. This gets us

   // the ICLRRuntimeHost pointer we’ll need to call Start.

   ICLRRuntimeHost *pCLR = NULL;

    HRESULT hr = CorBindToRuntimeEx(

      L"v2.0.31113",

   L"wks",

      STARTUP_CONCURRENT_GC,

      CLSID_CLRRuntimeHost,

      IID_ICLRRuntimeHost,

      (PVOID*) &pCLR);

  // Get a pointer to the ICLRControl interface

ICLRControl *pCLRControl = NULL;

hr = pCLR->GetCLRControl(&pCLRControl);

// Call SetAppDomainManagerType to associate our domain manager with

// the process

pCLRControl->SetAppDomainManagerType(

L”BoatRaceHostRuntime, Version=1.0.0.0, PublicKeyToken=5cf360b40180107c, culture=neutral”,

      L"BoatRaceHostRuntime.BoatRaceDomainManager"

);

 

  // Start the CLR

   hr = pCLR->Start();

// rest of main() omitted…

}

Thanks,

Steven

This posting is provided "AS IS" with no warranties, and confers no rights.