views:

63

answers:

1

I know that when creating a DLL and declaring items as "Shared" (Static in C#) that they are instantiated when first called, and then that object reference lives on as the single reference.

So declaring a shared string property once set can be called again to retreive the same value. And that thread safety is then a Major concern within the application domain.

What happens outside of the application domain. If we put the assembly in the Global Application Cache (GAC) how many instances will exist?

For example a static property called "MyFileName" in a GAC'ed .dll.

Then we have two applications calling the GAC'ed .dll. How many instances of "MyFileName" would exist? Would changes to MyFileName from Application one copy over to the value that Application Two uses?

+2  A: 

The dll is instantiated within the AppDomain, so there are as many different copies as there are AppDomains. Data does not transfer between AppDomains. Putting the DLL in the GAC just makes it available to everything in one place, it doesn't change the memory model of .net.

Robert C. Barth
That is what I thought, but wanted to be 100% sure!
Mitchel Sellers