我在 ASP.NET Web 应用程序中使用企业库异常处理块。我昨天刚在工作中使用这个应用程序(非 VPN),一切正常。我今天在家工作,一旦我将表单验证到应用程序中,我就会收到此错误:
为 exceptionHandling 创建配置节处理程序时出错:无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version=4.1.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT 异常:0x80131040)(C:\Projects\ThesaurusSME\ThesaurusSME\web.config 第 5 行)
此错误在c:\EntLib41Src\Blocks\Common\Src\Configuration\SystemConfigurationSourceImplementation.cs中发生,在此方法中:
public override ConfigurationSection GetSection(string sectionName)
{
ConfigurationSection configurationSection = ConfigurationManager.GetSection(sectionName) as ConfigurationSection;
SetConfigurationWatchers(sectionName, configurationSection);
return configurationSection;
}
我检查了 bin 文件夹中的所有文件,都是 4.1.0.0。
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
引用这些部分的 web.config 的所有其他部分也显示 4.1.0.0。
如果有帮助,InnerException/FusionLog 会说:
/Users/heckacr1/AppData/Local/Temp/Temporary ASP.NET Files/root/ac718580/56b7f71/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。日志:尝试下载新 URL 文件:///C:/Users/heckacr1/AppData/Local/Temp/Temporary ASP.NET Files/root/ac718580/56b7f71/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling/Microsoft.Practices.EnterpriseLibrary .ExceptionHandling.DLL。日志:正在尝试下载新的 URL 文件:///C:/Projects/ThesaurusSME/ThesaurusSME/bin/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。EnterpriseLibrary.ExceptionHandling/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。日志:正在尝试下载新的 URL 文件:///C:/Projects/ThesaurusSME/ThesaurusSME/bin/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。EnterpriseLibrary.ExceptionHandling/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。日志:正在尝试下载新的 URL 文件:///C:/Projects/ThesaurusSME/ThesaurusSME/bin/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.DLL。 警告:比较程序集名称导致不匹配:公钥令牌错误:无法完成程序集设置(hr = 0x80131040)。探测终止。"
为什么只有当我离开有线 Intranet 并使用 VPN 时才会发生这种情况?