微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ASP.NET MVC尝试加载旧版本的Owin程序集

作为一个上下文,我正在开发一个ASP.NET MVC 5应用程序,该应用程序通过Microsoft的OWIN实现使用基于OAuth的身份验证,仅适用于此阶段的Facebook和Google.目前(截至v3.0.0,git-commit 4932c2f),FacebookAuthenticationoptions和GoogleOAuth2Authenticationoptions不提供任何财产来强制Facebook或Google分别在登录时重新验证用户(通过附加相应的查询字符串参数).

最初,我开始重写以下类:

> FacebookAuthenticationoptions
> GoogleOAuth2Authenticationoptions
> FacebookAuthenticationHandler(特别是AuthenticateCoreAsync())
> GoogleOAuth2AuthenticationHandler(特别是AuthenticateCoreAsync())

但是发现~CognificationHandler类被标记为内部.

所以我为Katana项目(http://katanaproject.codeplex.com/)提取了一份源代码并相应地修改了源代码.

编译之后,我发现有几个依赖项需要更新才能在MVC项目中使用这些更新的程序集(Microsoft.Owin.Security.Facebook和Microsoft.Owin.Security.Google):

> Microsoft.Owin
> Microsoft.Owin.Security
> Microsoft.Owin.Security.Cookies
> Microsoft.Owin.Security.OAuth
> Microsoft.Owin.Host.SystemWeb

这是通过将现有项目引用替换为3.0.0版本并在web.config中更新它们来完成的.好消息:该项目成功编译.

在调试中,我在启动时收到异常:

An exception of type ‘System.IO.FileLoadException’ occurred in [MVC web assembly].dll but was not handled in user code

Additional information: Could not load file or assembly ‘Microsoft.Owin.Security,Version=3.0.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)

基础异常表明Microsoft.AspNet.Identity.Owin在Startup.Auth.cs中从Startup.ConfigureAuth(IAppBuilder应用程序)调用app.UseExternalSignInCookie()时尝试加载Microsoft.Owin.Security的v2.1.0.

不幸的是,程序集(及其它依赖项,Microsoft.AspNet.Identity.Owin)不是Project Katana解决方案的一部分,我无法在线找到这些程序集的任何可访问存储库.

Are the Microsoft.AspNet.Identity assemblies open source,like the Katana project?
Is there a way to fool those assemblies to use the referenced v3.0.0 assemblies instead of v2.1.0? The /bin folder contains the 3.0.0 versions of the Owin assemblies.

我已经为Microsoft.AspNet.Identity.Owin升级了NuGet包,这仍然是一个问题.

有关如何解决此问题的任何想法?

解决方法

我更新到OWin 3.0.1并修复了问题:

工具 – > NuGet包管理器 – >管理NuGet包以获得解决方

搜索了列表中的引用(在NuGet.org下),并为Microsoft.Owin以及Microsoft.Owin.Security,Microsoft.Owin.Security.Google,Microsoft.Owin.Security.Facebook等安装了新的引用.

然后我检查了packages.config和Web.Config文件中的版本号,发现它已正确更新:

Packages.config示例:

<package id="Microsoft.Owin.Security.Google" version="3.0.1" TargetFramework="net45" />

Web.Config示例:

<assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />

原文地址:https://www.jb51.cc/aspnet/248178.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐