Visual Studio坚持我添加对已安装的NuGet软件包的旧版本的引用

问题描述 投票:0回答:1

我有这个课程,从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,版本= 2.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35”的引用。

但是我已经从NuGet安装了较新的Microsoft.Owin版本;我为什么不能使用它?由于其他NuGet软件包的依赖性,我无法降级到2.0.0.0。

如何告诉Visual Studio我要使用Microsoft.Owin的较新版本?

c# visual-studio nuget owin visual-studio-2019
1个回答
1
投票

[我想我已经知道了-我之前已将更改还原到我的csproj文件中,因此Microsoft.Owin程序包陷入了困境,根据NuGet进行了安装,但没有根据我的csproj文件进行安装。我不得不切换到旧版本以强制安装它,然后再切换回去。

© www.soinside.com 2019 - 2024. All rights reserved.