[英]Visual Studio is looking for an old Nuget Package with no publicKeyToken
[英]Visual Studio insists I add a reference to an old version of an already-installed NuGet package
我有這個 class,從 Microsoft 示例中稍作調整:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using Root.Web.TokenStorage;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
namespace Root.Web.Controllers
{
public class AccountController : Controller
{
public void SignIn()
{
if (!Request.IsAuthenticated)
{
// Signal OWIN to send an authorization request to Azure
Request.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
public ActionResult SignOut()
{
if (Request.IsAuthenticated)
{
var tokenStore = new SessionTokenStore(null,
System.Web.HttpContext.Current, ClaimsPrincipal.Current);
tokenStore.Clear();
Request.GetOwinContext().Authentication.SignOut(
CookieAuthenticationDefaults.AuthenticationType);
}
return RedirectToAction("Index", "Home");
}
}
}
在我得到 OWIN 上下文的那一行,我得到了這個錯誤:
錯誤 CS0012 類型“IOwinContext”在未引用的程序集中定義。 您必須添加對程序集“Microsoft.Owin,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”的引用。
但是我已經從 NuGet 安裝了更新版本的Microsoft.Owin
; 為什么我不能使用它? 由於其他 NuGet 軟件包的依賴關系,我無法降級到 2.0.0.0。
如何告訴 Visual Studio 我想使用較新版本的Microsoft.Owin
?
我想我明白了——我之前已經恢復了對我的 csproj 文件的更改,因此Microsoft.Owin
package 陷入了困境,根據 NuGet 安裝,但沒有根據我的 csproj 文件安裝。 我不得不切換到舊版本來強制安裝它,然后再切換回來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.