CannotUnloadAppDomainException-Klasse
Die Ausnahme, die bei einem fehlgeschlagenen Versuch, eine Anwendungsdomäne zu entladen, ausgelöst wird.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class CannotUnloadAppDomainException
Inherits SystemException
'Usage
Dim instance As CannotUnloadAppDomainException
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class CannotUnloadAppDomainException : SystemException
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class CannotUnloadAppDomainException : public SystemException
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
public class CannotUnloadAppDomainException extends SystemException
SerializableAttribute
ComVisibleAttribute(true)
public class CannotUnloadAppDomainException extends SystemException
Hinweise
CannotUnloadAppDomainException wird bei einem Entladeversuch ausgelöst:
Die Standardanwendungsdomäne, die für die Lebensdauer der Anwendung geladen sein muss.
Eine Anwendungsdomäne mit einem derzeit ausgeführten Thread, dessen Ausführung nicht sofort beendet werden kann.
Eine Anwendungsdomäne, die bereits entladen wurde.
CannotUnloadAppDomainException verwendet HRESULT COR_E_CANNOTUNLOADAPPDOMAIN mit dem Wert 0x80131015.
Eine Liste der anfänglichen Eigenschaftenwerte für eine Instanz von CannotUnloadAppDomainException finden Sie unter CannotUnloadAppDomainException-Konstruktoren.
Beispiel
Imports System
Imports System.Reflection
Imports System.Security.Policy
'Imports System.Data
'for evidence object
Class ADMultiDomain
' The following attribute indicates to loader that multiple application
' domains are used in this application.
<LoaderOptimizationAttribute(LoaderOptimization.MultiDomainHost)> _
Public Shared Sub Main()
' Create application domain setup information for new application domain.
Dim domaininfo As New AppDomainSetup()
domaininfo.ApplicationBase = System.Environment.CurrentDirectory
domaininfo.ApplicationName = "MyMultiDomain Application"
'Create evidence for the new appdomain from evidence of current application domain.
Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
' Create appdomain.
Dim newDomain As AppDomain = AppDomain.CreateDomain("MyMultiDomain", adevidence, domaininfo)
'Load an assembly into the new application domain.
Dim w As Worker = CType( _
newDomain.CreateInstanceAndUnwrap( _
[Assembly].GetExecutingAssembly().GetName().Name, _
"Worker"), _
Worker)
w.TestLoad()
'Unload the application domain, which also unloads the assembly.
AppDomain.Unload(newDomain)
End Sub 'Main
End Class 'ADMultiDomain
Class Worker
Inherits MarshalByRefObject
Friend Sub TestLoad()
' You must supply a valid assembly display name here.
[Assembly].Load("Text assembly name, Culture, PublicKeyToken, Version")
For Each assem As [Assembly] In AppDomain.CurrentDomain.GetAssemblies()
Console.WriteLine(assem.FullName)
Next
End Sub
End Class
using System;
using System.Reflection;
using System.Security.Policy; //for evidence object
class ADMultiDomain
{
// The following attribute indicates to loader that multiple application
// domains are used in this application.
[LoaderOptimizationAttribute( LoaderOptimization.MultiDomainHost)]
public static void Main()
{
// Create application domain setup information for new application domain.
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase = System.Environment.CurrentDirectory;
domaininfo.ApplicationName = "MyMultiDomain Application";
//Create evidence for the new appdomain from evidence of current application domain.
Evidence adevidence = AppDomain.CurrentDomain.Evidence;
// Create appdomain.
AppDomain newDomain = AppDomain.CreateDomain("MyMultiDomain", adevidence, domaininfo);
// Load an assembly into the new application domain.
Worker w = (Worker) newDomain.CreateInstanceAndUnwrap(
Assembly.GetExecutingAssembly().GetName().Name,
"Worker"
);
w.TestLoad();
//Unload the application domain, which also unloads the assembly.
AppDomain.Unload(newDomain);
}
}
class Worker : MarshalByRefObject
{
internal void TestLoad()
{
// You must supply a valid fully qualified assembly name here.
Assembly.Load("Text assembly name, Culture, PublicKeyToken, Version");
foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
Console.WriteLine(assem.FullName);
}
}
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;
ref class Worker : MarshalByRefObject
{
public:
void TestLoad()
{
// You must supply a valid fully qualified assembly name here.
Assembly::Load("Text assembly name, Culture, PublicKeyToken, Version");
for each (Assembly^ assem in AppDomain::CurrentDomain->GetAssemblies())
Console::WriteLine(assem->FullName);
}
};
//for evidence Object*
// The following attribute indicates to loader that multiple application
// domains are used in this application.
[LoaderOptimizationAttribute(LoaderOptimization::MultiDomainHost)]
int main()
{
// Create application domain setup information for new application domain.
AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
domaininfo->ApplicationName = "MyMultiDomain Application";
//Create evidence for the new appdomain from evidence of current application domain.
Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;
// Create appdomain.
AppDomain^ newDomain = AppDomain::CreateDomain( "MyMultiDomain", adevidence, domaininfo );
// Load an assembly into the new application domain.
Worker^ w = (Worker^) newDomain->CreateInstanceAndUnwrap(
Assembly::GetExecutingAssembly()->GetName()->Name,
"Worker"
);
w->TestLoad();
//Unload the application domain, which also unloads the assembly.
AppDomain::Unload(newDomain);
}
Vererbungshierarchie
System.Object
System.Exception
System.SystemException
System.CannotUnloadAppDomainException
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0
Siehe auch
Referenz
CannotUnloadAppDomainException-Member
System-Namespace
Object
Exception
AppDomain-Klasse
Thread