System.CannotUnloadAppDomainException Class

public class CannotUnloadAppDomainException : SystemException

Base Types

Object
  Exception
    SystemException
      CannotUnloadAppDomainException

Assembly

mscorlib

Library

RuntimeInfrastructure

Summary

Represents the error that occurs when an attempt to unload an application domain fails.

Description

CannotUnloadAppDomainException is thrown when there is an attempt to unload:

Example

The following example demonstrates an error that causes the CannotUnloadAppDomainException exception to be thrown.

using System;
using System.Threading;

public class CannotUnloadAppDomainExceptionTest {
  public static void Main() {
    AppDomain ad = Thread.GetDomain();
    AppDomain.Unload(ad);
  }
}
The output is

Unhandled Exception: System.CannotUnloadAppDomainException: The default domain cannot be unloaded.
   at System.AppDomain.Unload(AppDomain domain)
   at CannotUnloadAppDomainExceptionTest.Main()

See Also

System Namespace

Members

CannotUnloadAppDomainException Constructors

CannotUnloadAppDomainException() Constructor
CannotUnloadAppDomainException(System.String) Constructor
CannotUnloadAppDomainException(System.String, System.Exception) Constructor


CannotUnloadAppDomainException() Constructor

public CannotUnloadAppDomainException();

Summary

Constructs and initializes a new instance of the CannotUnloadAppDomainException class.

Description

This constructor initializes the System.CannotUnloadAppDomainException.Message property of the new instance to a system-supplied message that describes the error, such as "Attempt to unload the AppDomain failed." This message takes into account the current system culture.

The System.CannotUnloadAppDomainException.InnerException property of the new instance is initialized to null .

See Also

System.CannotUnloadAppDomainException Class, System Namespace

CannotUnloadAppDomainException(System.String) Constructor

public CannotUnloadAppDomainException(string message);

Summary

Constructs and initializes a new instance of the CannotUnloadAppDomainException class.

Parameters

message
A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

Description

This constructor initializes the System.CannotUnloadAppDomainException.Message property of the new instance using message. If message is null , the System.CannotUnloadAppDomainException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments.

The System.CannotUnloadAppDomainException.InnerException property of the new instance is initialized to null .

See Also

System.CannotUnloadAppDomainException Class, System Namespace

CannotUnloadAppDomainException(System.String, System.Exception) Constructor

public CannotUnloadAppDomainException(string message, Exception innerException);

Summary

Constructs and initializes a new instance of the CannotUnloadAppDomainException class.

Parameters

message
A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
innerException
An instance of Exception that is the cause of the current exception. If innerException is not a null reference, the current exception was raised in a catch block handling innerException .

Description

This constructor initializes the System.CannotUnloadAppDomainException.Message property of the new instance using message and the System.CannotUnloadAppDomainException.InnerException property using innerException. If message is null , the System.CannotUnloadAppDomainException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments.

[Note: For more information on inner exceptions, see System.Exception.InnerException.]

See Also

System.CannotUnloadAppDomainException Class, System Namespace