在测试服务器中部署后,Microsoft.Owin错误

问题描述:

将.net MVC应用程序部署到我的测试服务器后,出现此错误。
在开发机中正常工作

Am getting this error after deploying .net MVC application into my test server. In dev machine its working fine

/应用中的服务器错误。
无法加载文件或程序集 Microsoft.Owin,版本= 2.1.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)
说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

Server Error in '/' Application. Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.IO.FileLoadException:无法加载文件或程序集 Microsoft.Owin,Version = 2.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35或它的依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

源错误:

在执行过程中生成了未处理的异常当前的Web请求。可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

程序集加载跟踪:以下信息有助于确定为什么程序集' Microsoft.Owin,版本= 2.1.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'无法加载。

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

WRN:程序集绑定日志记录已关闭。
要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1。
注意:与程序集绑定相关的性能损失故障记录。
要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog]。

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

堆栈跟踪:

[FileLoadException:无法加载文件或程序集'Microsoft.Owin,Version = 2.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)
jp.Startup.ConfigureAuth(IAppBuilder应用程序)+0

[FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] jp.Startup.ConfigureAuth(IAppBuilder app) +0

[TargetInvocationException:对象的目标抛出了异常调用。]
System.RuntimeMethodHandle.InvokeMethod(对象目标,对象[]参数,签名sig,布尔构造函数)+0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象obj,对象[]参数,对象[]参数)+128
System.Reflection.RuntimeMethodInfo.Invoke(对象obj,BindingFlags invokeAttr,活页夹活页夹,对象[]参数,CultureInfo文化)+142
Owin.Loader。<> c__DisplayClass12。 b__b(IAppBuilder构建器)+93
Owin.Loader。<> c__DisplayClass1.b__0(IAppBuilder构建器)+212
Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action 1次启动)+873
Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(动作
1次启动)+51
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint( )+101
System.Threading.LazyInitializer.EnsureInitializedCore(T&目标,布尔值和放大器;初始化,Object& syncLock,Func`1 valueFactory)+135
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication上下文)+160
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext上下文,MethodInfo [ ]处理程序)+580
System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,MethodInfo []处理程序,IntPtr appContext,HttpContext上下文)+165
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext上下文) )+267
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+341

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +128 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +142 Owin.Loader.<>c__DisplayClass12.b__b(IAppBuilder builder) +93 Owin.Loader.<>c__DisplayClass1.b__0(IAppBuilder builder) +212 Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) +873 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +51 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +101 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +135 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +580 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +165 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +267 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +341

[HttpException(0x80004005):目标抛出了异常调用。]
System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+523
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+107
System.Web.HttpRuntime.ProcessRequestNotificationPrivate (IIS7WorkerRequest wr,HttpContext上下文)+688

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688

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

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0

这是由程序集版本未匹配引起的,可以通过重定向程序集版本进行修复,请参考 https:// docs。 microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

this is caused by assembly version miss match, and can be fixed by Redirecting Assembly Versions , please refer to https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions .

重定向可以由vs自动生成,请参考 https://docs.microsoft.com/zh-cn/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection

And redirections can be generated by vs automatically, please refer to https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection