5

Does ASP.NET load all assemblies into the AppDomain from the bin folder?

Why I ask is because I'm trying to look for specific implementations of an interface and it seems to be resolving them without an explicit Assembly.Load(...).

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • I think it loads all assemblies which are References of loaded DLLs. One of your loaded projects must be referencing the DLLs which contains the classes you are seeing. I am not certain of this though. – Jesse Webb Oct 19 '11 at 18:55
  • There isnt any direct project references. – Daniel A. White Oct 19 '11 at 18:57
  • Transitive projects references would still count, assuming the DLLs are in the bin folder. Like if A (your app) depends on B which depends on C and all 3 are in bin folder, C will end up being loaded automatically. – Jesse Webb Oct 19 '11 at 19:07
  • Let me elaborate. I have `Core`, `App`, `AnotherDll`. Both `App` and `AnotherDll` depend on `Core`. `App` doesn't know about `AnotherDll` but `AnotherDll` is in `App`'s bin. – Daniel A. White Oct 19 '11 at 19:09

2 Answers2

4

I think it does load them all, via System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory(). I get that in profiling stack traces but can't find much documentation of it.

Fellow SO'ers discuss controlling it here though: How to stop ASP.NET from loading all assemblies from bin on first load

Community
  • 1
  • 1
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
2

It will not load them unless they are referenced (either statically or dynamically). But the Bin folder is considered part of the probing path, so it will get used to try to load Assemblies.

tcarvin
  • 10,715
  • 3
  • 31
  • 52