Reputation: 4546
Could be a very naive question, but was wondering how this stuff works: Lets assume that we have 10 projects in Visual Studio, and 5 of them have references to an external DLL (say Ext.dll), using a relative path.
Now when my application is deployed an running on client machine, would Ext.dll get loaded 5 times in memory? Or would it just get loaded once and gets used by other referencing projects?
Upvotes: 3
Views: 131
Reputation:
Clr
load assembly in memory just once.
Note :for each instance of application Clr
load assembly again.
You can read Clr via c#.In chapter one you can learn many of these Concepts.
Upvotes: 3
Reputation: 81253
Assembly will be loaded only once in memory.
CLR first check if assembly already loaded in current AppDomain
, if not than assembly gets loaded under AppDomain otherwise symbols are resolved from the already loaded assembly.
Ofcourse unless you are manually creating another AppDomain which has its own set of assemblies.
Moreover, assembly with same version cannot be loaded in memory at same time. CLR doesn't allow that. But you can have different versions of same assembly to be loaded in memory and that too in case assemblies are strongly signed. But in your case version is same so CLR won't load same assembly twice anyhow.
If you want to check at certain interval time that what assemblies are loaded in a memory, you can use this piece of code to get all loaded assemblies:
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
Upvotes: 5