简体   繁体   English

错误CS0122由于其保护级别,“AuthenticationOptions”无法访问

[英]Error CS0122 'AuthenticationOptions' is inaccessible due to its protection level

I was following this guide to write my own Katana authentication middleware . 我按照本指南编写了自己的Katana身份验证中间件

Now I encountered a problem when I'm writing the AuthenticationOptions. 现在我在编写AuthenticationOptions时遇到了问题。 I get an "inaccessible due to its protection level" when I inherent from Microsoft.Owin.Security.AuthenticationOptions. 当我从Microsoft.Owin.Security.AuthenticationOptions固有时,我得到“由于其保护级别而无法访问”。 The thing is that this class is protected, so it should not be inaccessible? 问题是这个类是受保护的,所以它不应该是不可访问的? I have tried to do a clean and rebuild, but I still get the same error. 我试图做一个干净的重建,但我仍然得到同样的错误。 I must be missing something? 我肯定错过了什么?

My class: 我的课:

using Microsoft.Owin;
using Microsoft.Owin.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dummy
{
    public class DummyAuthenticationOptions : AuthenticationOptions
    {
        public DummyAuthenticationOptions(string userName, string userId)
            : base(Constants.DefaultAuthenticationType)
        {
            Description.Caption = Constants.DefaultAuthenticationType;
            CallbackPath = new PathString("/signin-dummy");
            AuthenticationMode = AuthenticationMode.Passive;
            UserName = userName;
            UserId = userId;
        }

        public PathString CallbackPath { get; set; }

        public string UserName { get; set; }

        public string UserId { get; set; }

        public string SignInAsAuthenticationType { get; set; }

        public ISecureDataFormat<AuthenticationProperties> StateDataFormat { get; set; }
    }
}

Microsoft.Owin.Security.AuthenticationOptions: Microsoft.Owin.Security.AuthenticationOptions:

namespace Microsoft.Owin.Security
{
    internal abstract class AuthenticationOptions
    {
        protected AuthenticationOptions(string authenticationType);

        public AuthenticationMode AuthenticationMode { get; set; }
        public string AuthenticationType { get; set; }
        public AuthenticationDescription Description { get; set; }
    }
}

The problem was that the AuthenticationOptions class was set to internal. 问题是AuthenticationOptions类设置为internal。 I downgraded the Microsft.Owin.Security package from 3.0.1 to 2.0.1. 我将Microsft.Owin.Security包从3.0.1降级到2.0.1。 Here the class is marked public so I was able to compile without problems. 这里的类被标记为public因此我能够毫无问题地编译。

Thanks to Dmitry Rotay 感谢Dmitry Rotay

暂无
暂无

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

相关问题 错误 CS0122:“GameManager.Instance”由于其保护级别 (CS0122) 而无法访问 - Error CS0122: 'GameManager.Instance' is inaccessible due to its protection level (CS0122) .NET Wrapper to C++ 代码:CS0122 由于其保护级别错误而无法访问 - .NET Wrapper to C++ code: CS0122 is inaccessible due to its protection level error 如何更正错误 CS0122:“WebHost”由于其保护级别而无法访问 - How to correct error CS0122: 'WebHost' is inaccessible due to its protection level CS0122:由于其保护级别,&#39;System.Configuration.StringUtil&#39;无法访问 - CS0122: 'System.Configuration.StringUtil' is inaccessible due to its protection level CS0122:“AmazonGlacierClient.ListVaults()”由于其保护级别而无法访问 - CS0122: 'AmazonGlacierClient.ListVaults()' is inaccessible due to its protection level 获取编译器错误CS0122 - 由于其保护级别,“成员”无法访问 - 同时尝试访问其他项目中的类 - Getting the Compiler Error CS0122 - 'member' is inaccessible due to its protection level - while trying to access a class in a different project x:绑定事件绑定的语法,给出错误CS0122:由于保护级别而无法访问 - x:Bind syntax for event binding giving error CS0122: inaccessible due to protection level CS0122 Form1.AvgWaiting 由于其保护级别和 C# Windows 表格中的甘特图而无法访问 - CS0122 Form1.AvgWaiting is inaccessible due to its protection level and gantt chart in C# Windows Form 错误:由于其保护级别而无法访问 - Error: Inaccessible due to its protection level 成员由于保护级别错误而无法访问 - Member is inaccessible due to its protection level error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM