简体   繁体   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

I have a MVC project with OAuth authentication, every time I try to debug the project i get a FileLoadException upon configuring the IAppBuilder. 我有一个带有OAuth身份验证的MVC项目,每次我尝试调试项目时,在配置IAppBuilder时都会遇到FileLoadException。 I have installed version 3.0.1 of Microsoft.Owin.Security.Oauth using the PMC but I guess somewhere still lies a reference to an older version of the package because... 我已经使用PMC安装了Microsoft.Owin.Security.Oauth 3.0.1版,但我想某处仍然是对旧版本软件包的引用,因为......

This is the exception: 这是例外:

在此输入图像描述

This is where it is thrown: 这是抛出的地方:

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

This is my packages.config: 这是我的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>

I tried adding binding redirect as such: 我尝试添加绑定重定向

<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> 

Can´t understand why this doesn´t work, does Visual Studio make a difference between 3.0.1 and 3.0.1.0? 无法理解为什么这不起作用,Visual Studio在3.0.1和3.0.1.0之间有区别吗?

I tried removing obj and bin folders, cleaning projects and rebuilding them. 我尝试删除obj和bin文件夹,清理项目并重建它们。

I tried deleting all nuget packages and restoring them. 我尝试删除所有nuget包并恢复它们。

I tried reinstalling all Owin packages. 我尝试重新安装所有Owin软件包。

I´ve used Agent Ransack to search my entire source directory for any file containing Microsoft.Owin.Security.OAuth but found no references to version 2.0.0.0 or any other version besides the correct 3.0.1.0. 我使用Agent Ransack在我的整个源目录中搜索包含Microsoft.Owin.Security.OAuth的任何文件,但没有找到对版本2.0.0.0或除正确3.0.1.0之外的任何其他版本的引用。

I´m stuck, any ideas? 我卡住了,有什么想法?

Ok, so just in case anyone else ends up with this problem; 好吧,以防万一其他人最终遇到这个问题;

The problem was that the Microsoft.AspNet.Identity.Owin package is depending on Microsoft.Owin.Security.OAuth and there was a mismatch in version. 问题是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" />

Apparently, even though Microsoft.AspNet.Identity.Owin requires >= v2.0 of Microsoft.Owin.Security.OAuth , having v3+ of Microsoft.Owin.Security.OAuth will break the compatibility (major version inconsistency). 显然,即使Microsoft.AspNet.Identity.Owin要求> = V2.0版Microsoft.Owin.Security.OAuth的,具有V3 + Microsoft.Owin.Security.OAuth将打破兼容性(主要版本不一致)。

After I had updated Microsoft.AspNet.Identity.Owin package and its adjacent family members Microsoft.AspNet.Identity.EntityFramework and Microsoft.AspNet.Identity.Core I removed all packages, bin and obj folders and rebuilt solution. 在我更新了Microsoft.AspNet.Identity.Owin包及其相邻的家庭成员Microsoft.AspNet.Identity.EntityFrameworkMicrosoft.AspNet.Identity.Core我删除了所有包,bin和obj文件夹并重建了解决方案。 Voila! 瞧!

A tip to the VS2013+ Ultimate user is to use the NuGet Package Visualizer when exploring package dependencies. VS2013 + Ultimate用户的一个提示是在探索包依赖关系时使用NuGet包Visualizer。

Check your references. 检查您的参考。 Remove the Microsoft.Owin.Security.OAuth from everywhere, then restore all nuget packages. 从任何地方删除Microsoft.Owin.Security.OAuth,然后恢复所有nuget包。

暂无
暂无

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

相关问题 无法加载文件或程序集 Microsoft.VisualStudio.Shell,版本 = 2.0.0.0 - Could not load file or assembly Microsoft.VisualStudio.Shell, Version=2.0.0.0 Microsoft.Owin.Security.Oauth承载令牌授权拦截 - Microsoft.Owin.Security.Oauth Bearer Token Authorization Interception 无法加载文件或程序集&#39;Microsoft.Azure.CosmosDB.BulkImport,版本= 2.0.0.0 - Could not load file or assembly 'Microsoft.Azure.CosmosDB.BulkImport, Version=2.0.0.0 SignalR 2.0错误:无法加载文件或程序集Microsoft.Owin.Security - SignalR 2.0 error: Could not load file or assembly Microsoft.Owin.Security 通过asp.net Microsoft.Owin.Security.OAuth获取访问令牌 - get access token via asp.net Microsoft.Owin.Security.OAuth 运行时错误:无法加载文件或程序集&#39;Microsoft.Owin,版本= 3.0.0.0…Azure移动服务 - Runtime error: Could not load file or assembly 'Microsoft.Owin, Version=3.0.0.0…Azure mobile services 无法加载文件或程序集 Microsoft.Owin 3.0.0 到 3.0.1 - Could not load file or assembly Microsoft.Owin 3.0.0 to 3.0.1 无法加载文件或程序集&#39;System.Web.WebPages.Razor,版本= 2.0.0.0,win8 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, win8 '无法加载文件或程序集 'netstandard,版本 = 2.0.0.0,...'。 不应加载引用程序集以执行 - 'Could not load file or assembly 'netstandard, Version=2.0.0.0, ...'. Reference assemblies should not be loaded for execution 无法加载文件或程序集&#39;System.Data version = 2.0.0.0&#39;或其依赖项之一 - Could not load file or assembly 'System.Data version=2.0.0.0' or one of its dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM