最初,我开始重写以下类:
> 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包,这仍然是一个问题.
有关如何解决此问题的任何想法?
解决方法
工具 – > 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" />