Reputation: 69
I have created a new application domain and load my assembly into it.
Assembly assembly = dom.Load("bookOne");
Every thing went well. the application used resource dictionary and etc. but when I tried to unload the dll to free memory with this code my application close without any error or warning:
try
{
AppDomain.Unload(dom);
}
catch (CannotUnloadAppDomainException)
{
Console.WriteLine("Book Unloaded!" + " 4");
AppDomain.Unload(dom);
GC.Collect();
}
The output window shows these after sudden exit:
A first chance exception of type 'System.AppDomainUnloadedException' occurred in mscorlib.dll A first chance exception of type 'System.AppDomainUnloadedException' occurred in mscorlib.dll The thread 'vshost.RunParkingWindow' (0x1df8) has exited with code 0 (0x0). The thread '' (0xfcc) has exited with code 0 (0x0).
Upvotes: 0
Views: 1098
Reputation: 5677
A first chance exception of type 'System.AppDomainUnloadedException' occurred in mscorlib.dll
If you are getting AppDomainUnloadedException ,then you can ignore this because AppDomainUnloadedException is thrown when an Application Domain is unloaded and that is what you want.
From the msdn
The exception that is thrown when an attempt is made to access an unloaded application domain
Upvotes: 2