c# - 为什么在我的 ASP.Net 网站上大约每周一次出现 System.IO.FileLoadException : Could not load file or assembly,?

标签 c# asp.net assemblies enterprise-library fileloadexception

我有一个相当简单的内部 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 重置解决了这个问题。
  • 我们在单个网络服务器上运行相同的代码,没有任何问题。然后,我们将该站点移动到两个新的负载平衡(使用粘性 session )网络服务器(所有三个 Windows Server 2003 R2 Standard Edition SP1)。现在,每个负载平衡网络服务器大约每周一次突然抛出此异常。
    • 我能想到的唯一主要区别是,我在负载平衡服务器上安装了 4.0 .NET 框架.该网站仍在 ASP.NET 2.0 下运行,所以我看不出这会是个问题
  • 我已将索引服务配置为不搜索“Temporary ASP.NET Files”文件夹,但没有帮助。
  • 我们在网站的任何地方都使用 Microsoft.Practices.EnterpriseLibrary.Data dll。几乎每个页面都使用我们的逻辑 dll,而逻辑 dll 又利用 EnterpriseLibrary dll。
  • 虽然错误只发生过一次,但我什至查看了哪些进程正在锁定“Temporary ASP.NET Files”文件夹中的 dll,这与工作正常的服务器上的锁没有任何不同。
  • 一旦错误开始,每次都会出错,直到执行 iisreset

任何人都可以提供任何见解,我们将不胜感激。如果我遗漏了什么,请告诉我。

谢谢!

最佳答案

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

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

关于c# - 为什么在我的 ASP.Net 网站上大约每周一次出现 System.IO.FileLoadException : Could not load file or assembly,?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3150133/

相关文章:

c# - Quartz.net JobStoreTX 作业保存问题

c# - 将编码的 UI 测试导出到 TFS

asp.net - 发现了多种与名为 'Home'的 Controller 匹配的类型。 (两个区域,相同的 Controller 名称)

asp.net - Entity Framework 数据库初始化: Timeout when initializing new Azure SqlDatabase

c# - 在 Direct X 11 游戏中挂接 Direct X Endscene

c# - 使用多个连接和谓词优化 LINQ 查询

c# - 可以在 IIS 中对静态 html 页面进行后处理吗?

asp.net - 如何将 jQuery UI 按钮图标添加到输入按钮?

c# - 在运行时交换强签名程序集

.net - 调试动态加载的程序集