Visual Studio 坚持要我添加对已安装 NuGet 包的旧版本的引用
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 上下文的那一行,我收到了这个错误:
Error CS0012 The type 'IOwinContext' is defined in an assembly that is not referenced. You must add a reference to assembly '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
包陷入了困境,根据 NuGet 安装但没有根据我的 csproj 文件安装。我不得不切换到旧版本以强制安装它,然后切换回来。
我有这个 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 上下文的那一行,我收到了这个错误:
Error CS0012 The type 'IOwinContext' is defined in an assembly that is not referenced. You must add a reference to assembly '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
包陷入了困境,根据 NuGet 安装但没有根据我的 csproj 文件安装。我不得不切换到旧版本以强制安装它,然后切换回来。