1

In my ASP.NET MVC project, I want to make my service classes as a class library.
I want to add a few dlls to my main project.
The dlls that will be added have assembly references on their own. Some of them might are the same, such as System etc.
Does this architecture effect the main project's performance?

Is only one System-dll loaded or is it loaded separately for every class library?

Florian K
  • 602
  • 9
  • 30
Mehmet
  • 739
  • 1
  • 6
  • 17
  • An assembly that is referenced as both a project reference and a dependent assemblies reference will only be copied once to the output location for the current project as the project's reference. You will need to manually reference other assemblies referenced by dependencies but not by your main project. – Ross Bush Mar 08 '17 at 14:47

1 Answers1

2

For a given .NET process, there's (by default) as single AppDomain, which is the environment into which DLLs are loaded and resolved. This means that if you reference DLL X (Say, System.dll), and also reference DLL Y which also references System.dll, it will only be loaded once into the appdomain, and further references will reuse the same instance in memory.

This is true for custom assemblies as well. If both X and Y reference Z.dll, it's still only loaded once.

You can rest easily knowing that you're not causing any bloat here.

Avner Shahar-Kashtan
  • 14,492
  • 3
  • 37
  • 63