Let's look at when and how asp.net runtime loads a particular dll. Your asp.net application needs to load lot of dlls to run your application.Following are some of the common scenarios n which your application will try to load a dll into the application.
- Your reference dlls and dependencies of referenced dlls
In your visual studio project file,we will be referring dlls whatever we need.This basically adds an entry into the project file (csproj or vbproj file) like below
<Reference Include="System.Web.Http, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath> <Private>True</Private> </Reference>
- You are not referring a dll but you can dynamically load the dlls using Reflection
- In your code, You may be using Assembly.Load or any of it's variants .So at the runtime,this tries to load that assembly and it's dependent assemblies
- Your configuration(web.config) may be referring that dll .For example you may have any configuration entry which will be using type
<log4net> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> </layout> </appender>
- similarly you may have an httphandler or module configuration where you are loading the type
<httpHandlers> <add verb="*" path="test" type="MyHttpHandler.CustomHandler,CustomHandler"/> </httpHandlers>
- Another possibility is that you have this dll simply present in your bin directory.By default asp.net will try to load all the dlls present in the bin directory because of root web.config(C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config) setting
<system.web> <compilation> <assemblies> <add assembly="*" /> </assemblies> </compilation> </system.web>
- This one may be rare,I have seen CLR profilers dynamically inject DLLs to the process.
Hope this helps!