See Also: CannotUnloadAppDomainException Members
CannotUnloadAppDomainException is thrown when there is an attempt to unload the following:
The default application domain, which must remain loaded during the lifetime of the application.
An application domain with a running thread that cannot immediately stop execution.
An application domain that has already been unloaded.
CannotUnloadAppDomainException uses the HRESULT COR_E_CANNOTUNLOADAPPDOMAIN, which has the value 0x80131015.
For a list of initial property values for an instance of CannotUnloadAppDomainException, see the CannotUnloadAppDomainException.#ctor constructors.
The following example demonstrates an error that causes the CannotUnloadAppDomainException exception to be thrown.
C# Example
using System;
using System.Threading;
public class CannotUnloadAppDomainExceptionTest {
public static void Main() {
AppDomain ad = Thread.GetDomain();
AppDomain.Unload(ad);
}
}
The output is
Example
Unhandled Exception: System.CannotUnloadAppDomainException: The default domain cannot be unloaded. at System.AppDomain.Unload(AppDomain domain) at CannotUnloadAppDomainExceptionTest.Main()