We’ve all been halted in ASP.NET development when we seemingly do a normal compile, and then our website won’t work. It won’t even start up. Here’s a rough error you may see:
Server Error in ‘/MyWebApp’ Application
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Access is denied: ‘mydll’.
Line 169: <add assembly=<System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a>/>
Line 170: <add assembly=<System.EnterpriseServices, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a>/>
Line 171: <add assembly=<*>/>
Line 172: </assemblies>
Source File: c:winntmicrosoft.netframeworkv1.0.3705Configmachine.config Line: 171
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0
Most of the time, your website worked just fine. It has happened to me when I’ve just made an update to the web.config file. What causes this is that the website AppDomain tries to load, and it can’t. A change to the web.config causes a recycle of the AppDomain and a reload of the website. When the website loads, a copy of every assembly is loaded into the Temporary ASP.NET Files directory. If that directory is locked, or files in the directory are locked, this process can’t complete, and we’ll see this error.
The most common cause is the Windows Indexing Service. I don’t really need this service, so I’ve disabled it. I don’t get this error anymore. Technically speaking, any process that may lock files in that directory may cause this error, so technically virus scanners, Google Desktop search, etc may lock those files and cause this error, but I’ve only connected this with the Windows Indexing Service.
Microsoft, in this Knowledge Base (KB) article, recommends exactly that: disabling the Indexing Service.