System.CannotUnloadAppDomainException Class

The exception that is thrown when an attempt to unload an application domain fails.

See Also: CannotUnloadAppDomainException Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public class CannotUnloadAppDomainException : SystemException

Remarks

CannotUnloadAppDomainException is thrown when there is an attempt to unload the following:

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.

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Example

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()

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0