繁体   English   中英

无法加载文件或程序集Microsoft.Owin.Security.OAuth,Version = 2.0.0.0

[英]Could not load file or assembly Microsoft.Owin.Security.OAuth, Version=2.0.0.0

我有一个带有OAuth身份验证的MVC项目,每次我尝试调试项目时,在配置IAppBuilder时都会遇到FileLoadException。 我已经使用PMC安装了Microsoft.Owin.Security.Oauth 3.0.1版,但我想某处仍然是对旧版本软件包的引用,因为......

这是例外:

在此输入图像描述

这是抛出的地方:

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app); //Exception is thrown here
    }
}

这是我的packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
  <package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
  <package id="EntityFramework" version="6.0.0" targetFramework="net45" />
  <package id="jQuery" version="1.10.2" targetFramework="net45" />
  <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
  <package id="log4net" version="2.0.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Modernizr" version="2.6.2" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="Unity" version="3.5.1404.0" targetFramework="net45" />
  <package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>

我尝试添加绑定重定向

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security.OAuth" PublicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
</dependentAssembly> 

无法理解为什么这不起作用,Visual Studio在3.0.1和3.0.1.0之间有区别吗?

我尝试删除obj和bin文件夹,清理项目并重建它们。

我尝试删除所有nuget包并恢复它们。

我尝试重新安装所有Owin软件包。

我使用Agent Ransack在我的整个源目录中搜索包含Microsoft.Owin.Security.OAuth的任何文件,但没有找到对版本2.0.0.0或除正确3.0.1.0之外的任何其他版本的引用。

我卡住了,有什么想法?

好吧,以防万一其他人最终遇到这个问题;

问题是Microsoft.AspNet.Identity.Owin包依赖于Microsoft.Owin.Security.OAuth并且版本不匹配。

  <package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" />

显然,即使Microsoft.AspNet.Identity.Owin要求> = V2.0版Microsoft.Owin.Security.OAuth的,具有V3 + Microsoft.Owin.Security.OAuth将打破兼容性(主要版本不一致)。

在我更新了Microsoft.AspNet.Identity.Owin包及其相邻的家庭成员Microsoft.AspNet.Identity.EntityFrameworkMicrosoft.AspNet.Identity.Core我删除了所有包,bin和obj文件夹并重建了解决方案。 瞧!

VS2013 + Ultimate用户的一个提示是在探索包依赖关系时使用NuGet包Visualizer。

检查您的参考。 从任何地方删除Microsoft.Owin.Security.OAuth,然后恢复所有nuget包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM