public class CannotUnloadAppDomainException : SystemException
Object
Exception
SystemException
CannotUnloadAppDomainException
mscorlib
RuntimeInfrastructure
Represents the error that occurs when an attempt to unload an application domain fails.
CannotUnloadAppDomainException is thrown when there is an attempt to unload:
- 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.
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()
System Namespace
CannotUnloadAppDomainException Constructors
CannotUnloadAppDomainException() Constructor
CannotUnloadAppDomainException(System.String) Constructor
CannotUnloadAppDomainException(System.String, System.Exception) Constructor
public CannotUnloadAppDomainException();
Constructs and initializes a new instance of the CannotUnloadAppDomainException class.
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
.
System.CannotUnloadAppDomainException Class, System Namespace
public CannotUnloadAppDomainException(string message);
Constructs and initializes a new instance of the CannotUnloadAppDomainException class.
- 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.
This constructor initializes the System.CannotUnloadAppDomainException.Message property of the new instance using message. If message isnull
, 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
.
System.CannotUnloadAppDomainException Class, System Namespace
public CannotUnloadAppDomainException(string message, Exception innerException);
Constructs and initializes a new instance of the CannotUnloadAppDomainException class.
- 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 .
This constructor initializes the System.CannotUnloadAppDomainException.Message property of the new instance using message and the System.CannotUnloadAppDomainException.InnerException property using innerException. If message isnull
, 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.]
System.CannotUnloadAppDomainException Class, System Namespace