help with dll reference count in a circular reference situation in c# 4.0
Iam maintaining a large code base I have inherited (ported from vb6 to C#.net 1.1, then to .net 2.0/c# and so on). I have this scenario
My main projec开发者_StackOverflowt references two DLLs - DLL-A and DLL-B
DLL-B references DLL-A. Both dll's and my main project are in 3 separate namespaces.
1) Are 2 copies of DLL-A being loaded in memory ? (dll ref count)
2) How do I find out how many copies of a .net dll is loaded in mem ? (which tool is normally used)
thank you
No, DLL-A will only be loaded once. It's just like everything references mscorlib - but only one copy of that is loaded in.
Unless you're doing something funky (using multiple AppDomains, loading assemblies with reflection, hosting multiple CLRs side-by-side) you'll only get one copy of an assembly reference.
1) No. When the application or library (DLL-B) uses a type from DLL-A, it will be loaded into memory. When it's used later by the other source, the same copy will be used.
2) Only one copy of the assembly will get loaded into the AppDomain of your process. In a normal application, this means a single copy will get loaded of each assembly (ie: dll) you use.
There is no "reference counting" happening here.
精彩评论