Customizing the Microsoft .NET Framework Common Language Runtime

Once loaded into a process, the CLR can never be completely removed. That is, there is no way to guarantee that all files and data structures associated with the CLR are cleaned up and all the memory they required is returned. You can, however, disable the CLR. Specifically, when you disable the CLR, it no longer is able to run managed code in the process. The process itself is not damaged in the sense that unmanaged code continues to run just fine, but further attempts to run managed code are not honored.

You disable the CLR by using the Stop method on ICLRRuntimeHost. Calls to Stop must be paired with calls to ICLRRuntimeHost::Start, which is discussed earlier in the chapter. That is, you must call Stop once for each call you made to Start for the CLR to be disabled. It's also important to note that once the CLR has been disabled using Stop, it can never be restarted in the same process again.

    Категории