views:

258

answers:

2

I have a web application that works fine for a while (a few days) and then starts throwing FileLoadException's when instantiating a class that references an external dll.

  • I'm not explicitly loading the assembly with any of the Assembly static methods. I'm just instantiating a class that itself instantiates a class from the referenced library.
  • I ran Process Monitor and just monitored the application path. I only get "PATH NOT FOUND" results for the source code file where the error occurs (compiled in debug mode so I assume this is just part of .NET trying to show the line where the error occurred when dumping the stack trace)
  • This is running on a dedicated server in-house. The application is running on a .NET 3.5 application pool along with another web site built using the same referenced dll's. The other web site has a lot more traffic but never gets this error.
  • The application is load-balanced across 3 web servers and all 3 get this issue at some point.

I turned on assembly binding logging on one of the web servers. Here is what the stack trace looks like:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.FileLoadException: Could not load file or assembly 'Project.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
File name: 'Project.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at ...
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = Project.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/websites/ProjectPath/
LOG: Initial PrivatePath = C:\websites\ProjectPath\bin
Calling assembly : WebApp, Version=1.0.3723.37743, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\websites\ProjectPath\web.config
LOG: Using host configuration file: \\?\c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d77c161e/8751390/Project.Library.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d77c161e/8751390/Project.Library/Project.Library.DLL.
LOG: Attempting download of new URL file:///C:/websites/ProjectPath/bin/Project.Library.DLL.
ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.

   --- End of inner exception stack trace ---
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.myaccount_home_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I'm not very familiar with debugging file load exceptions, so any help is greatly appreciated (what else I can do to debug, etc.).

Thanks.

A: 

Andrew,

I'm having the same exact issue you're describing here. Have you found a solution/fix?

Daryl
A: 

Probably you have impersonation turned on in the Web.config. Turn it off if impersonation is not really necessary. Otherwise you will need to do some handy tricks with the permissions on the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files folder to allow your impersonated users to access assemblies in that folder.

Vertigo