【问题标题】:common.logging - Redirect found in application configuration filecommon.logging - 在应用程序配置文件中找到的重定向
【发布时间】:2012-09-28 16:31:29
【问题描述】:

我通过 nuget 将 common.logging.log4net 添加到了我的 Visual Studio 2012 解决方案中。

common.logging.log4net 版本。 - 2.0.1 common.logging 版本。 - 2.0.0 log4net - 版本。 1.2.10

当我在本地构建/运行它时,我通过浏览器看到以下异常:

无法加载文件或程序集“Common.Logging”或其其中之一 依赖关系。定位程序集的清单定义不 匹配程序集引用。 (来自 HRESULT 的异常:0x80131040) 说明:执行过程中发生未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。

异常详细信息:System.IO.FileLoadException:无法加载文件或 程序集“Common.Logging”或其依赖项之一。位于 程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

堆栈跟踪:

[FileLoadException: 无法加载文件或程序集“Common.Logging” 或其依赖项之一。定位程序集的清单定义 与程序集引用不匹配。 (HRESULT 的例外情况: 0x80131040)]

[FileLoadException: 无法加载文件或程序集 'Common.Logging, 版本=2.1.1.0,文化=中性,PublicKeyToken=af08829b84f0328e' 或 它的依赖项之一。定位程序集的清单定义 与程序集引用不匹配。 (HRESULT 的例外情况: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名、字符串代码库、证据 assemblySecurity、RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+210
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,用于自省的布尔值)+242
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String 组装字符串)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔星指令)+122

它正在寻找 Common.Logging Version=2.1.1.0,它找不到,因为它没有加载。现在,当我调试应用程序时,我看到了以下异常,这有点不同:

LOG:此绑定在默认加载上下文中开始。

LOG:使用应用程序配置文件: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG:使用主机配置文件: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG:使用来自的机器配置文件 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG:此时未将策略应用于参考(私有、 自定义、部分或基于位置的程序集绑定)。

LOG:正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/e97e0952/56ab271f/Common.Logging.DLL。

LOG:正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL。

LOG:正在尝试下载新 URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL。

LOG:使用应用程序配置文件: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG:使用主机配置文件: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG:使用来自的机器配置文件 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG:在应用程序配置文件中找到重定向:2.0.0.0 重定向到 2.1.1.0。

LOG:后策略参考:Common.Logging,版本=2.1.1.0, 文化=中立,PublicKeyToken=af08829b84f0328e

LOG:正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/e97e0952/56ab271f/Common.Logging.DLL。

LOG:正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL。

LOG:正在尝试下载新 URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL。警告: 比较程序集名称导致不匹配:次要版本 ERR:无法完成程序集的设置(hr = 0x80131040)。探测 终止。

堆栈跟踪:

[FileLoadException: 无法加载文件或程序集“Common.Logging” 或其依赖项之一。定位程序集的清单定义 与程序集引用不匹配。 (HRESULT 的例外情况: 0x80131040)]

[FileLoadException: 无法加载文件或程序集 'Common.Logging, 版本=2.1.1.0,文化=中性,PublicKeyToken=af08829b84f0328e' 或 它的依赖项之一。定位程序集的清单定义 与程序集引用不匹配。 (HRESULT 的例外情况: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名、字符串代码库、证据 assemblySecurity、RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+210
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,用于自省的布尔值)+242
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String 组装字符串)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔星指令)+122

[ConfigurationErrorsException: 无法加载文件或程序集 'Common.Logging,版本=2.1.1.0,文化=中性, PublicKeyToken=af08829b84f0328e' 或其依赖项之一。这 定位程序集的清单定义与程序集不匹配 参考。 (HRESULT 异常:0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔型星指令)+12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 preStartInitListPath) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, 异常 appDomainCreationException) +1151

[HttpException (0x80004005): 无法加载文件或程序集 'Common.Logging,版本=2.1.1.0,文化=中性, PublicKeyToken=af08829b84f0328e' 或其依赖项之一。这 定位程序集的清单定义与程序集不匹配 参考。 (HRESULT 异常:0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+12722601

版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.17929

不知道为什么它试图重定向到 2.1.1.0(根据日志)

汤姆

【问题讨论】:

标签: c# logging nuget log4net common.logging


【解决方案1】:

我认为这一行暗示了这个问题:

LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 2.1.1.0.

检查您的应用程序配置文件 (app.config) 中的程序集重定向,告诉它在任何请求版本 2.0.0.0 时尝试加载版本 2.1.1.0。

【讨论】:

    猜你喜欢
    • 2014-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多