PC Review


Reply
Thread Tools Rate Thread

DLL unloading automatically

 
 
Yash Ganthe
Guest
Posts: n/a
 
      3rd Nov 2009
Hi,

In my program, I load a DLL using Assembly.LoadFrom(). The program has
no Reference added to the DLL. It is loaded dynamically. The DLL has a
class with a static constructor. I can see that it executes when the
assembly is loaded. However, after a few hours, the static constructor
executes again. There is only one place in the program from which the
Assembly is loaded and this does not happen in a loop.
This makes me think that the assembly has got Unloaded somehow and has
automatically been reloaded. In what circumstances is this possible?
Is there any other explanation to the static constructor being
executed twice?

This is on .NET 3.0, C#

Thanks,
Yash
 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      3rd Nov 2009
Yash Ganthe wrote:
> Hi,
>
> In my program, I load a DLL using Assembly.LoadFrom(). The program has
> no Reference added to the DLL. It is loaded dynamically. The DLL has a
> class with a static constructor. I can see that it executes when the
> assembly is loaded. However, after a few hours, the static constructor
> executes again. There is only one place in the program from which the
> Assembly is loaded and this does not happen in a loop.
> This makes me think that the assembly has got Unloaded somehow and has
> automatically been reloaded. In what circumstances is this possible?
> Is there any other explanation to the static constructor being
> executed twice?
>
> This is on .NET 3.0, C#
>
> Thanks,
> Yash


Try displaying the stack trace in the static constructor to see why it
might be called.

--
Mike
 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      5th Nov 2009
On Nov 3, 10:45 am, Yash Ganthe <yas...@gmail.com> wrote:
> Hi,
>
> In my program, I load a DLL using Assembly.LoadFrom(). The program has
> no Reference added to the DLL. It is loaded dynamically. The DLL has a
> class with a static constructor. I can see that it executes when the
> assembly is loaded. However, after a few hours, the static constructor
> executes again. There is only one place in the program from which the
> Assembly is loaded and this does not happen in a loop.
> This makes me think that the assembly has got Unloaded somehow and has
> automatically been reloaded. In what circumstances is this possible?
> Is there any other explanation to the static constructor being
> executed twice?
>
> This is on .NET 3.0, C#
>
> Thanks,
> Yash


Unless you loaded the assembly in a separate AppDomain, I don't think
it will be unloaded until the App closes.

I'm not sure how instances of static classes are handled by the
garbage collector, but perhaps your class is being collected somehow,
so that the next time you access the static members, the static
constructor is being executed again.

 
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
DLL unloading automatically Yash Ganthe Microsoft Dot NET Framework 2 5th Nov 2009 02:34 PM
DLL unloading automatically Yash Ganthe Microsoft C# .NET 2 5th Nov 2009 02:34 PM
Unloading the Vxd....98 Vinay Microsoft Windows 2000 File System 0 14th Apr 2004 01:50 PM
Re: Unloading a dll Tom Swift Windows XP Performance 0 16th Oct 2003 07:25 PM
Re: unloading sascha78@gmx.net Microsoft Dot NET Compact Framework 0 17th Sep 2003 09:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:38 PM.