| |
 |
|
| .NET DotNet Forum Index » General Discussion » DLL unloading automatically... |
|
Page 1 of 1 |
|
| Author |
Message |
| Yash Ganthe... |
Posted: Tue Nov 03, 2009 6:45 am |
|
|
|
Guest
|
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 |
|
|
| Back to top |
|
|
|
| Family Tree Mike... |
Posted: Tue Nov 03, 2009 5:33 pm |
|
|
|
Guest
|
Yash Ganthe wrote:
Quote: 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 |
|
|
| Back to top |
|
|
|
| Chris Dunaway... |
Posted: Thu Nov 05, 2009 4:34 am |
|
|
|
Guest
|
On Nov 3, 10:45 am, Yash Ganthe <yas... at (no spam) gmail.com> wrote:
Quote: 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. |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 22, 2009 3:37 am
|
|