다음을 통해 공유


Unloading Domains and Shutting Down a Process

Application domains can be unloaded without stopping the entire process. Hosts can take advantage of this feature to unload code that is no longer needed, thereby reducing memory use and increasing the scalability of their application.

The System.AppDomain class includes a static method called Unload that hosts can use to unload a particular application domain. AppDomain.Unload performs a graceful shutdown, not unloading the domain until there are no more active threads.

Assemblies that have been loaded into the default domain or assemblies that have been loaded as domain-neutral cannot be unloaded without shutting down the entire process or unloading the runtime from the process.

The ICorRuntimeHost interface includes a method called Stop that hosts can use to forcefully unload the runtime from the process. Calls to Stop unload all domains immediately, including the default domain and all domain-neutral code, and remove the runtime entirely from the process. After Stop has been called on a process, the runtime cannot be loaded back into that process. A new process must be created to begin running managed code again.

See Also

Hosting the Common Language Runtime | AppDomain.Unload Method