我有一个由Visual Studio 2013制作的全新MVC5项目,当我尝试在本地启动它时它工作正常。但是,当我发布到我的Azure网站时,我得到了这个头版:
无法加载文件或程序集“Microsoft.Owin.Security.Cookies”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)
堆栈跟踪:
[FileLoadException:无法加载文件或程序集'Microsoft.Owin.Security.Cookies'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)]
[FileLoadException:无法加载文件或程序集'Microsoft.Owin.Security.Cookies,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,> Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)+77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)+16 System.Reflection.Assembly.Load(String assemblyString)+28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+38
[ConfigurationErrorsException:无法加载文件或程序集'Microsoft.Owin.Security.Cookies,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+736 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)+130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()+91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath,Boolean& isRefAssemblyLoaded)+284 System.Web.Compilation.BuildManager.ExecutePreAppStart()+153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+521
[HttpException(0x80004005):无法加载文件或程序集“Microsoft.Owin.Security.Cookies,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+9930568 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+254
我安装了3.0.0版的Microsoft.Owin,它在我的Web.config和packages.config中说了同样的事情。我该如何解决这个问题?
答案 0 :(得分:84)
尝试:
Microsoft.Owin.Security
从2.1.0升级到3.0.0 Microsoft.Owin.Security.Cookies
从2.1.0升级到3.0.0 Microsoft.Owin.Security.OAuth
从2.1.0升级到3.0.0 升级上述软件包后,问题得以解决。
答案 1 :(得分:1)
您可以通过以下方式做到这一点
NuGet 解决方案和Web.Config
都必须考虑以下版本Microsoft.Owin.Security
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security.Cookies
Microsoft.Owin