PC Review


Reply
Thread Tools Rate Thread

Assembly not getting unloaded

 
 
Ashutosh
Guest
Posts: n/a
 
      23rd Oct 2008
Hi,
I have this simple code
AppDomain d = AppDomain.CreateDomain("test123");
Assembly a = d.Load("ClassLibrary1, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=c4510fb7f9c15154");
MethodInfo m = o.GetType().GetMethod("Hello");
m.Invoke(o, null);
AppDomain.Unload(d);

after the Unload statement, the ClassLibary1 is still loaded into the
process address space. How can I make sure that it's unloaded?

Thanks & Regards,
Ashutosh
 
Reply With Quote
 
 
 
 
Ashutosh
Guest
Posts: n/a
 
      23rd Oct 2008
Oops!! missed this line
object o = a.CreateInstance("ClassLibrary1.TestClass123");

it should be after the d.Load method call.....


Ashutosh wrote:
> Hi,
> I have this simple code
> AppDomain d = AppDomain.CreateDomain("test123");
> Assembly a = d.Load("ClassLibrary1, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=c4510fb7f9c15154");
> MethodInfo m = o.GetType().GetMethod("Hello");
> m.Invoke(o, null);
> AppDomain.Unload(d);
>
> after the Unload statement, the ClassLibary1 is still loaded into the
> process address space. How can I make sure that it's unloaded?
>
> Thanks & Regards,
> Ashutosh

 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      24th Oct 2008
Hi Ashutosh ,

Yes, I can reproduce this issue. Even though you are loading the assembly
in the context of the new appdomain, you are returning a reference to it in
the default appdomain, which causes it to load the assembly in both
appdomains. So the assembly will not be unloaded from the process space.
You need to write a class that is remoted back to the default appdomain,
and provide a method, e.g. LoadAndRun() that does the actual loading. The
articles below provide the detailed steps:
"Assembly.Unload? Use AppDomain.Unload instead."
http://codebetter.com/blogs/ranjan.s.../08/61574.aspx
"Dynamic Plugins: Using the AppDomain Class to Load and Unload Code"
http://www.devsource.com/c/a/Using-V...e-codeAppDomai
ncode-Class-to-Load-and-Unload-Code/

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppCrash ContentTool.dll-unloaded =?Utf-8?B?Ri5MLg==?= Windows Vista Installation 1 24th Apr 2007 11:26 AM
Unloaded Assembly still occours in parent AppDomain Basti Microsoft C# .NET 1 2nd Nov 2006 09:06 AM
unloaded user account =?Utf-8?B?TWF1cmljaW8gQ2VyaXNvbGE=?= Windows XP Help 0 20th Aug 2006 09:40 PM
Application_End is not fired when app unloaded. Why? =?Utf-8?B?VmxhZCBIcnlib2s=?= Microsoft ASP .NET 4 11th Jan 2005 03:21 PM
Assembly version from unloaded assembly bw Microsoft Dot NET Framework 5 14th Aug 2003 06:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.