Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CannotUnloadAppDomainException Constructor ()

Initializes a new instance of the CannotUnloadAppDomainException class.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

CannotUnloadAppDomainException ()
public CannotUnloadAppDomainException ()
public function CannotUnloadAppDomainException ()

This constructor initializes the 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 following table shows the initial property values for an instance of CannotUnloadAppDomainException.




a null reference (Nothing in Visual Basic).


The localized error message string.

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;

ref class Worker : MarshalByRefObject
   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())

//for evidence Object*
// The following attribute indicates to loader that multiple application
// domains are used in this application.

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(

   //Unload the application domain, which also unloads the assembly.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft