为什么我得到System.IO.FileLoadException:无法加载文件或程序集,大约每周一次在我的ASP.Net网站上?

Dar*_*ryl 6 c# asp.net assemblies enterprise-library fileloadexception

我有一个相当简单的内部ASP.Net网站,每周大约加载一次Microsoft.Practices.EnterpriseLibrary.Data dll.这是Exception消息:

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
File name: 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
   at foobar.Intranet.Logic.Data.UserDB.SelectByUserName(String userName)
   at foobar.Intranet.Logic.Info.User.ValidateUser(String userName) in F:\Development\foobar\foobar\foobar.Intranet.Logic\Info\User.cs:line 130
   at Login.ValidateUser(String username, String password) in e:\foobar\foobar.Intranet\Login.aspx.cs:line 32

=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///E:/foobar/foobar.Intranet/
LOG: Initial PrivatePath = E:\foobar\foobar.Intranet\bin Calling assembly : foobar.Intranet.Logic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\foobar\foobar.Intranet\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/foobar.intranet/668896d8/82d7e51c/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/foobar.intranet/668896d8/82d7e51c/Microsoft.Practices.EnterpriseLibrary.Data/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL file:///E:/foobar/foobar.Intranet/bin/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.
Run Code Online (Sandbox Code Playgroud)

注意事项:

  • 一个简单的IIS重置修复了这个问题.
  • 我们在单个Web服务器上运行相同的代码,没有任何问题.然后,我们将站点移动到两个新的负载平衡(使用粘性会话)Web服务器(所有三个Windows Server 2003 R2 Standard Edition SP1).现在,每个负载均衡的Web服务器每周一次就抛出这个异常.
    • 我能想到的唯一主要区别是,我已经在负载均衡服务器上安装了4.0 .NET框架.该网站仍然在ASP.NET 2.0下运行,所以我不知道这将是一个什么问题
  • 我已将索引服务配置为不搜索"Temporary ASP.NET Files"文件夹,但它没有帮助.
  • 我们在我们的网站上使用Microsoft.Practices.EnterpriseLibrary.Data dll.几乎每个页面都使用我们的逻辑DLL,而后者又使用EnterpriseLibrary dll.
  • 虽然发生过一次的错误,我甚至想看看哪些进程在"Temporary ASP.NET Files"文件夹中锁定了dll,并且它与服务器上的锁没有任何不同.
  • 一旦错误开始,它每次都会出错,直到执行iisreset

任何人都可以提供的见解将非常感激.如果我错过了什么,请告诉我.

谢谢!

Dav*_*ale 3

看一下程序集绑定日志查看器。它可能会为您指明正确的方向。

我快速浏览了其他 SO 答案,有人建议该应用程序可能是针对 DLL 的签名版本开发的,但生产运行时只能访问未签名的版本。您的产品似乎正在加载未签名的程序集 ( PublicKeyToken=null)。