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

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.

注意事项:
  • 一个简单的IIS重置可解决此问题。
  • 我们在同一台Web服务器上运行了相同的代码,没有任何问题。然后,我们将该站点移至两个新的负载平衡(使用粘性 session )的Web服务器(所有三个Windows Server 2003 R2 Standard Edition SP1)。现在,每个负载平衡的Web服务器大约每周一次抛出该异常。
  • 我能想到的唯一主要区别是,我已经在负载平衡服务器上安装了4.0 .NET框架。该网站仍在ASP.NET 2.0下运行,因此我看不出这是一个问题
  • 我已将索引服务配置为不搜索“ASP.NET临时文件”文件夹,但这没有帮助。
  • 我们在我们的网站上到处都使用Microsoft.Practices.EnterpriseLibrary.Data dll。几乎每个页面都使用我们的逻辑dll,而后者又利用了EnterpriseLibrary dll。
  • 虽然发生了一次错误,但我什至还查看了哪些进程正在将DLL锁定在“Temporary ASP.NET Files”文件夹中,与正常工作的服务器上的锁没有什么不同。
  • 一旦错误开始,它将每一次出错,直到执行iisreset为止

  • 任何人都可以提供的任何见解将不胜感激。让我知道我是否错过了什么。

    谢谢!

    最佳答案

    看看Assembly Binding Log Viewer。它可能会为您指明正确的方向。

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

    09-25 18:31
    查看更多