错误CS0122' AuthenticationOptions'由于其保护级别而无法访问

时间:2016-04-19 07:21:52

标签: c# inheritance visual-studio-2015 owin katana

我关注此guide to write my own Katana authentication middleware

现在我在编写AuthenticationOptions时遇到了问题。 由于其保护等级,我得到了一个无法接近的状态"当我从Microsoft.Owin.Security.AuthenticationOptions固有时。问题是这个类是受保护的,所以它不应该是不可访问的?我试图做一个干净的重建,但我仍然得到同样的错误。我一定错过了什么?

我的课程:

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:

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; }
    }
}

1 个答案:

答案 0 :(得分:0)

问题是AuthenticationOptions类设置为内部。我将Microsft.Owin.Security包从3.0.1降级到2.0.1。这里的类被标记为public,所以我能够毫无问题地编译。

感谢Dmitry Rotay