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