Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DLL unloading automatically

0 views
Skip to first unread message

Yash Ganthe

unread,
Nov 3, 2009, 11:45:27 AM11/3/09
to
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

Family Tree Mike

unread,
Nov 3, 2009, 5:33:12 PM11/3/09
to

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

--
Mike

Chris Dunaway

unread,
Nov 5, 2009, 9:34:17 AM11/5/09
to

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.

0 new messages