Share via


When and how does asp.net runtime load dlls ?

Let's look at when and how asp.net runtime loads a particular dll. Your asp.net code needs to load lot of dlls to run your application.When you run your asp.net application/website ,typically it will be under IISExpress (iisexpress.exe) or IIS(w3wp.exe).

For a bare minimum asp.net application without any custom dlls created using a default VS template running under w3wp.exe , Looking at the dlls loaded using debugging tools for windows , we can see

  • 24 .NET assemblies
  • 35 IIS dlls (C:\windows\System32\inetsrv) - this depends on the IIS installation and modules,handlers configured.
  • 62 Windows System libraries(ntdll,kernel32)
  • 8 .NET framework dlls (clr.dll,webengine4.dll,mscoreei.dll etc)

Note: These numbers can vary based on the version of .NET framework,OS you are running.

You can see a full list of dlls and where it loaded from below windbg output.

 

          Base TimeStamp                     Module
            7ff7ba9d0000 57899b8a Jul 16 07:57:22 2016 c:\windows\system32\inetsrv\w3wp.exe
            7ffdd02d0000 5965abad Jul 12 10:25:09 2017 C:\windows\SYSTEM32\ntdll.dll
            7ffdce0c0000 59028368 Apr 28 05:18:56 2017 C:\windows\System32\KERNEL32.DLL
            7ffdcd3d0000 5965ac8c Jul 12 10:28:52 2017 C:\windows\System32\KERNELBASE.dll
            7ffdd0230000 57899b47 Jul 16 07:56:15 2016 C:\windows\System32\msvcrt.dll
            7ffdcff40000 594a140e Jun 21 12:07:02 2017 C:\windows\System32\combase.dll
            7ffdcd6a0000 578997b5 Jul 16 07:41:01 2016 C:\windows\System32\ucrtbase.dll
            7ffdcd860000 57a558cf Aug 06 08:56:07 2016 C:\windows\System32\RPCRT4.dll
            7ffdcd1e0000 57899aef Jul 16 07:54:47 2016 C:\windows\System32\bcryptPrimitives.dll
            7ffdac080000 57899b15 Jul 16 07:55:25 2016 c:\windows\system32\inetsrv\iisutil.dll
            7ffdce780000 57899904 Jul 16 07:46:36 2016 C:\windows\System32\advapi32.dll
            7ffdcdde0000 57899a7c Jul 16 07:52:52 2016 C:\windows\System32\sechost.dll
            7ffdce5a0000 57dacda4 Sep 15 22:04:44 2016 C:\windows\System32\WS2_32.dll
            7ffdcc7c0000 57899b97 Jul 16 07:57:35 2016 C:\windows\System32\kernel.appcore.dll
            7ffdcbae0000 57899b3a Jul 16 07:56:02 2016 C:\windows\SYSTEM32\ntmarta.dll
            7ffdce610000 584a7939 Dec 09 14:58:25 2016 C:\windows\System32\user32.dll
            7ffdcd840000 57a05800 Aug 02 13:51:20 2016 C:\windows\System32\win32u.dll
            7ffdcff00000 57dace36 Sep 15 22:07:10 2016 C:\windows\System32\GDI32.dll
            7ffdcd250000 59327d2b Jun 03 14:41:07 2017 C:\windows\System32\gdi32full.dll
            7ffdb1b20000 57899bca Jul 16 07:58:26 2016 c:\windows\system32\inetsrv\w3wphost.dll
            7ffdce890000 594a17f6 Jun 21 12:23:42 2017 C:\windows\System32\OLEAUT32.dll
            7ffdcd7a0000 578997a4 Jul 16 07:40:44 2016 C:\windows\System32\msvcp_win.dll
            7ffdac000000 57899a7d Jul 16 07:52:53 2016 c:\windows\system32\inetsrv\nativerd.dll
            7ffdcc2f0000 57899ab7 Jul 16 07:53:51 2016 C:\windows\SYSTEM32\ncrypt.dll
            7ffdc5670000 57899b3a Jul 16 07:56:02 2016 C:\windows\SYSTEM32\XmlLite.dll
            7ffdcc680000 584a7c7e Dec 09 15:12:22 2016 C:\windows\SYSTEM32\bcrypt.dll
            7ffdae830000 578997a1 Jul 16 07:40:41 2016 C:\windows\SYSTEM32\ktmw32.dll
            7ffdcc2b0000 57899b58 Jul 16 07:56:32 2016 C:\windows\SYSTEM32\NTASN1.dll
             2dcb0f50000 57899bc8 Jul 16 07:58:24 2016 c:\windows\system32\inetsrv\IISRES.DLL
            7ffdcc210000 57899b44 Jul 16 07:56:12 2016 C:\windows\SYSTEM32\CRYPTSP.dll
            7ffdcbc10000 57899b12 Jul 16 07:55:22 2016 C:\windows\system32\rsaenh.dll
            7ffdcc230000 57899bc7 Jul 16 07:58:23 2016 C:\windows\SYSTEM32\CRYPTBASE.dll
            7ffdce950000 57899991 Jul 16 07:48:57 2016 C:\windows\System32\clbcatq.dll
            7ffdaeac0000 57899ac6 Jul 16 07:54:06 2016 C:\windows\system32\mlang.dll
            7ffd7f6d0000 594223b0 Jun 15 11:35:36 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\webengine4.dll
            7ffdcde40000 57899a03 Jul 16 07:50:51 2016 C:\windows\System32\PSAPI.DLL
            7ffdb3740000 5849f946 Dec 09 05:52:30 2016 C:\windows\SYSTEM32\MSVCR120_CLR0400.dll
            7ffdcbe90000 57899b1c Jul 16 07:55:32 2016 C:\windows\SYSTEM32\USERENV.dll
            7ffdcc790000 57899b70 Jul 16 07:56:56 2016 C:\windows\System32\profapi.dll
            7ffdbbc90000 578999e5 Jul 16 07:50:21 2016 C:\windows\SYSTEM32\mscoree.dll
            7ffdbbb00000 575a1357 Jun 10 06:39:43 2016 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
            7ffdce060000 5789988d Jul 16 07:44:37 2016 C:\windows\System32\SHLWAPI.dll
            7ffdbc520000 57899b7f Jul 16 07:57:11 2016 C:\windows\SYSTEM32\VERSION.dll
            7ffd9be30000 593718eb Jun 07 02:34:43 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
            7ffd89570000 5965b173 Jul 12 10:49:47 2017 C:\windows\system32\inetsrv\iiscore.dll
            7ffdb0b20000 57899bbd Jul 16 07:58:13 2016 c:\windows\system32\inetsrv\W3TP.dll
            7ffdcc410000 584a7ca9 Dec 09 15:13:05 2016 C:\windows\SYSTEM32\SspiCli.dll
            7ffd89550000 5789986c Jul 16 07:44:04 2016 c:\windows\system32\inetsrv\w3dt.dll
            7ffdc08e0000 5965b198 Jul 12 10:50:24 2017 C:\windows\SYSTEM32\HTTPAPI.dll
            7ffdc4f60000 57899b54 Jul 16 07:56:28 2016 C:\windows\system32\napinsp.dll
            7ffdc4f80000 57899b21 Jul 16 07:55:37 2016 C:\windows\system32\pnrpnsp.dll
            7ffdca380000 57899a4d Jul 16 07:52:05 2016 C:\windows\system32\NLAapi.dll
            7ffdcc070000 57899a81 Jul 16 07:52:57 2016 C:\windows\System32\mswsock.dll
            7ffdcbdd0000 5965b0e4 Jul 12 10:47:24 2017 C:\windows\SYSTEM32\DNSAPI.dll
            7ffdcdd70000 57899be7 Jul 16 07:58:55 2016 C:\windows\System32\NSI.dll
            7ffdcbd90000 58ba5a9b Mar 04 11:41:39 2017 C:\windows\SYSTEM32\IPHLPAPI.DLL
            7ffdc9f90000 57899b79 Jul 16 07:57:05 2016 C:\windows\System32\winrnr.dll
                58910000 4e5dcc75 Aug 31 11:23:57 2011 C:\Program Files\Bonjour\mdnsNSP.dll
            7ffdc0800000 57899bae Jul 16 07:57:58 2016 C:\windows\System32\wshbth.dll
            7ffdb0f80000 57899bae Jul 16 07:57:58 2016 C:\Windows\System32\rasadhlp.dll
            7ffdc4000000 57899809 Jul 16 07:42:25 2016 C:\windows\System32\fwpuclnt.dll
            7ffdb1b10000 57899b80 Jul 16 07:57:12 2016 C:\windows\System32\inetsrv\loghttp.dll
            7ffd9ec50000 57899bbf Jul 16 07:58:15 2016 C:\windows\System32\inetsrv\cachuri.dll
            7ffd9ec10000 57899bc1 Jul 16 07:58:17 2016 C:\windows\System32\inetsrv\cachfile.dll
            7ffd82c70000 57899bd8 Jul 16 07:58:40 2016 C:\windows\System32\inetsrv\cachtokn.dll
            7ffd82c50000 57899baa Jul 16 07:57:54 2016 C:\windows\System32\inetsrv\cachhttp.dll
            7ffd82980000 57899b98 Jul 16 07:57:36 2016 C:\windows\System32\inetsrv\compdyn.dll
            7ffd82960000 57899b85 Jul 16 07:57:17 2016 C:\windows\System32\inetsrv\compstat.dll
            7ffd82950000 57899bdc Jul 16 07:58:44 2016 C:\windows\System32\inetsrv\defdoc.dll
            7ffd82780000 57899bd2 Jul 16 07:58:34 2016 C:\windows\System32\inetsrv\dirlist.dll
            7ffd82770000 57899bc1 Jul 16 07:58:17 2016 C:\windows\System32\inetsrv\protsup.dll
            7ffd82760000 57899bb9 Jul 16 07:58:09 2016 C:\windows\System32\inetsrv\static.dll
            7ffd82750000 57899b5f Jul 16 07:56:39 2016 C:\windows\System32\inetsrv\authanon.dll
            7ffd82740000 57899bb4 Jul 16 07:58:04 2016 C:\windows\System32\inetsrv\authbas.dll
            7ffd82720000 57899b93 Jul 16 07:57:31 2016 C:\windows\System32\inetsrv\authsspi.dll
            7ffdc8c70000 57899b4e Jul 16 07:56:22 2016 C:\windows\SYSTEM32\wkscli.dll
            7ffdcbe80000 57899bb3 Jul 16 07:58:03 2016 C:\windows\SYSTEM32\netutils.dll
            7ffd82660000 57899bab Jul 16 07:57:55 2016 C:\windows\System32\inetsrv\authmap.dll
            7ffd82650000 57899bb6 Jul 16 07:58:06 2016 C:\windows\System32\inetsrv\modrqflt.dll
            7ffd82640000 58ba6010 Mar 04 12:04:56 2017 C:\windows\System32\inetsrv\custerr.dll
            7ffd7f6b0000 57899b8b Jul 16 07:57:23 2016 C:\windows\System32\inetsrv\iisetw.dll
            7ffd7f680000 57899bac Jul 16 07:57:56 2016 C:\windows\System32\inetsrv\iisfreb.dll
            7ffd7f650000 57899b9c Jul 16 07:57:40 2016 C:\windows\System32\inetsrv\isapi.dll
            7ffd7f630000 57899baf Jul 16 07:57:59 2016 C:\windows\System32\inetsrv\filter.dll
            7ffdccf60000 58ba5a76 Mar 04 11:41:02 2017 C:\windows\System32\shcore.dll
            7ffdcdb30000 594a1722 Jun 21 12:20:10 2017 C:\windows\System32\ole32.dll
            7ffd82630000 57899bdb Jul 16 07:58:43 2016 C:\windows\System32\inetsrv\validcfg.dll
            7ffd7f620000 57899beb Jul 16 07:58:59 2016 C:\windows\System32\inetsrv\warmup.dll
            7ffd7f610000 57899be0 Jul 16 07:58:48 2016 C:\windows\System32\inetsrv\iiswsock.dll
            7ffd7f600000 57899b9a Jul 16 07:57:38 2016 C:\windows\SYSTEM32\websocket.dll
            7ffd7f590000 5540f74f Apr 29 20:52:55 2015 C:\windows\system32\inetsrv\rewrite.dll
            7ffd7f580000 575a1609 Jun 10 06:51:13 2016 C:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll
            7ffd7f570000 57899bd9 Jul 16 07:58:41 2016 C:\windows\system32\inetsrv\wbhst_pm.dll
            7ffd7f560000 594223ac Jun 15 11:35:32 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\webengine.dll
            7ffd975d0000 5937153c Jun 07 02:19:00 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\mscorlib\2ef49acbb43c068f6ddf1587283b5f29\mscorlib.ni.dll
            7ffd969a0000 594222b6 Jun 15 11:31:26 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System\51d981c86573c6074d73a12f87da3986\System.ni.dll
            7ffd8d8f0000 59371136 Jun 07 02:01:50 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Core\4d107b26fd5fe2cf378283cf24699d07\System.Core.ni.dll
            7ffd7f780000 594223b3 Jun 15 11:35:39 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web\b1e1919144cbf8786ca79c390642db91\System.Web.ni.dll
            7ffdcc5e0000 578999a8 Jul 16 07:49:20 2016 C:\windows\SYSTEM32\sxs.dll
            7ffd7f540000 59422294 Jun 15 11:30:52 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.8dc504e4#\66442736ce51fd7892a05270e15a946d\System.Web.ApplicationServices.ni.dll
            7ffd9af10000 575a13f8 Jun 10 06:42:24 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Configuration\5e7dd553c9f2940ca72c5afc30a2fe8a\System.Configuration.ni.dll
            7ffd8c9a0000 59371139 Jun 07 02:01:53 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xml\17b3fd9b9923f2e8da0d5df9dc5b609c\System.Xml.ni.dll
            7ffd9ece0000 593714c5 Jun 07 02:17:01 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
            7ffd7f4f0000 586fe66a Jan 07 00:18:10 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Runt19c51595#\8e2830e338181c0c201509098765f60d\System.Runtime.Caching.ni.dll
            7ffd7f3e0000 575a1496 Jun 10 06:45:02 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.B83e9cb53#\3ee1a749338e05dc5a6ac40bb868efd0\Microsoft.Build.Utilities.v4.0.ni.dll
            7ffdce9f0000 5980ca88 Aug 02 00:08:00 2017 C:\windows\System32\shell32.dll
            7ffdccf10000 57899b3c Jul 16 07:56:04 2016 C:\windows\System32\cfgmgr32.dll
            7ffdcc830000 594a1598 Jun 21 12:13:36 2017 C:\windows\System32\windows.storage.dll
            7ffdcc740000 57899a1f Jul 16 07:51:19 2016 C:\windows\System32\powrprof.dll
            7ffd7f120000 575a146f Jun 10 06:44:23 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.JScript\70e1cca52f7d5ba5e0f55753338eb4fc\Microsoft.JScript.ni.dll
            7ffd7ef30000 575a13fe Jun 10 06:42:30 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.CSharp\39e569728e57a61c672a402afd2c2063\Microsoft.CSharp.ni.dll
            7ffd88630000 59371adb Jun 07 02:42:59 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Data\bcfb45702eaed659a625f9e582e0c6e9\System.Data.ni.dll
            7ffd882d0000 59371adb Jun 07 02:42:59 2017 C:\windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll
            7ffdcd010000 590280d1 Apr 28 05:07:53 2017 C:\windows\System32\CRYPT32.dll
            7ffdcc7b0000 57899b43 Jul 16 07:56:11 2016 C:\windows\System32\MSASN1.dll
            7ffd7ed10000 575a184c Jun 10 07:00:52 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.Services\1b420f3032bdd53860886e9e15a0271e\System.Web.Services.ni.dll
            7ffd81680000 575a13ff Jun 10 06:42:31 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Drawing\4020667f84c6f2d0cd2f6583db692637\System.Drawing.ni.dll
            7ffd7ec10000 575a15c7 Jun 10 06:50:07 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Ente96d83b35#\5dc5dabf1d2c1c8b2365439b10cd4f65\System.EnterpriseServices.ni.dll
            7ffd7e890000 586fef01 Jan 07 00:54:49 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.IdentityModel\348b87c3df924292a29990830e295620\System.IdentityModel.ni.dll
            7ffd88f30000 586fef04 Jan 07 00:54:52 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Runteb92aa12#\01cc14f75abe10b45fd68595c58ecf2d\System.Runtime.Serialization.ni.dll
            7ffd7d0f0000 586fef27 Jan 07 00:55:27 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.ServiceModel\e36dc787f1a40a0cf4ee8a7219db5f64\System.ServiceModel.ni.dll
            7ffd7cd60000 594222c7 Jun 15 11:31:43 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.28b9ef5a#\85c6da5d659566ab5bc0b8242e6aa5e7\System.Web.Extensions.ni.dll
            7ffdb10d0000 575a13f7 Jun 10 06:42:23 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xml.Linq\9d61f786f91079fc8e6adc1acf3cc2b3\System.Xml.Linq.ni.dll
            7ffda12f0000 575a1417 Jun 10 06:42:55 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Comp46f2b404#\81a98a7e0fb91b661c064562cb6ede98\System.ComponentModel.DataAnnotations.ni.dll
            7ffd7caf0000 593715d3 Jun 07 02:21:31 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xaml\1b65c4db6aecbaf2ec4b3bd36ead1286\System.Xaml.ni.dll
            7ffd7ca60000 575a133c Jun 10 06:39:16 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Ente96d83b35#\5dc5dabf1d2c1c8b2365439b10cd4f65\System.EnterpriseServices.Wrapper.dll
            7ffd7cac0000 575a133c Jun 10 06:39:16 2016 C:\windows\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll
            7ffd7ca10000 575a1416 Jun 10 06:42:54 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.82d5542b#\892955b378251d274e472e4c017db003\System.Web.RegularExpressions.ni.dll
            7ffd7ca00000 57899bc9 Jul 16 07:58:25 2016 C:\windows\system32\inetsrv\gzip.dll
            7ffdcbc50000 57899ba3 Jul 16 07:57:47 2016 C:\windows\System32\DPAPI.DLL

 

What we are interested in the above list is when and how asp.net runtime loads those 24 dlls (.NET framework assemblies)  .This number can vary based on your application and that is what we are going to look .The dlls loaded from C:\windows\system32\ and from .NET framework (C:\Windows\Microsoft.NET\Framework64\v4.0.30319) stays same for most of the applications based on the version of .NET framework and OS you are running.

 

Following are some of the common scenarios n which your application will try to load a .dll(.NET assembly) 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=5.2.3.0, 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>

 

Hope this helps!