AppDomainUnloadedException Class
The exception that is thrown when an attempt is made to access an unloaded application domain.
For a list of all members of this type, see AppDomainUnloadedException Members.
System.Object
System.Exception
System.SystemException
System.AppDomainUnloadedException
[Visual Basic] <Serializable> Public Class AppDomainUnloadedException Inherits SystemException [C#] [Serializable] public class AppDomainUnloadedException : SystemException [C++] [Serializable] public __gc class AppDomainUnloadedException : public SystemException [JScript] public Serializable class AppDomainUnloadedException extends SystemException
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
AppDomainUnloadedException uses the HRESULT COR_E_APPDOMAINUNLOADED, which has the value 0x80131014.
For a list of initial property values for an instance of AppDomainUnloadedException, see the AppDomainUnloadedException constructors.
Example
[Visual Basic] Imports System Imports System.Reflection Imports System.Security.Policy 'for evidence object Class ADUnload Public Shared Sub Main() 'Create evidence for the new appdomain. Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence ' Create the new application domain. Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence) Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName)) Console.WriteLine(("child domain: " + domain.FriendlyName)) ' Unload the application domain. AppDomain.Unload(domain) Try Console.WriteLine() ' Note that the following statement creates an exception because the domain no longer exists. Console.WriteLine(("child domain: " + domain.FriendlyName)) Catch e As AppDomainUnloadedException Console.WriteLine("The appdomain MyDomain does not exist.") End Try End Sub 'Main End Class 'ADUnload [C#] using System; using System.Reflection; using System.Security.Policy; //for evidence object class ADUnload { public static void Main() { //Create evidence for the new appdomain. Evidence adevidence = AppDomain.CurrentDomain.Evidence; // Create the new application domain. AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence); Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName); Console.WriteLine("child domain: " + domain.FriendlyName); // Unload the application domain. AppDomain.Unload(domain); try { Console.WriteLine(); // Note that the following statement creates an exception because the domain no longer exists. Console.WriteLine("child domain: " + domain.FriendlyName); } catch (AppDomainUnloadedException e) { Console.WriteLine("The appdomain MyDomain does not exist."); } } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; using namespace System::Security::Policy; //for evidence Object* int main() { //Create evidence for the new appdomain. Evidence* adevidence = AppDomain::CurrentDomain->Evidence; // Create the new application domain. AppDomain* domain = AppDomain::CreateDomain(S"MyDomain", adevidence); Console::WriteLine(S"Host domain: {0}", AppDomain::CurrentDomain->FriendlyName); Console::WriteLine(S"child domain: {0}", domain->FriendlyName); // Unload the application domain. AppDomain::Unload(domain); try { Console::WriteLine(); // Note that the following statement creates an exception because the domain no longer exists. Console::WriteLine(S"child domain: {0}", domain->FriendlyName); } catch (AppDomainUnloadedException* /*e*/) { Console::WriteLine(S"The appdomain MyDomain does not exist."); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Mscorlib (in Mscorlib.dll)
See Also
AppDomainUnloadedException Members | System Namespace | AppDomain | Exception | Handling and Throwing Exceptions