2016-04-19 21 views
1

Ich folgte dieser guide to write my own Katana authentication middleware.Fehler CS0122 t 'AuthenticationOptions' ist aufgrund seiner Schutzstufe nicht zugänglich

Jetzt stieß ich auf ein Problem, wenn ich die AuthenticationOptions schreibe. Ich bekomme ein "unzugänglich aufgrund seiner Schutzstufe", wenn ich von Microsoft.Owin.Security.AuthenticationOptions inhärent bin. Die Sache ist, dass diese Klasse geschützt ist, also sollte sie nicht unzugänglich sein? Ich habe versucht, eine saubere und wieder aufzubauen, aber ich bekomme immer noch den gleichen Fehler. Ich muss etwas verpasst haben?

Meine Klasse:

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

Inernal Klassen können nur von der Montage sie in deklariert sind, zugegriffen werden. Sind Sie sicher, dass Sie die gleiche Version von 'Microsoft.Owin.Security' verwenden, dass der Autor des Artikels verwendet ? Ich habe gerade die Quellen des Beispiels des Autors von GitHub geöffnet, und alles sieht gut dort aus. Und die 'AuthenticationOptions'-Klasse ist in dieser Version der Bibliothek (2.0.1+) öffentlich. –

+0

Ich verwende neueste stabile (3.0.1). Ich bekomme das Paket mit nugget, wenn das Hilfe ist. Ich habe auf 2.0.1 heruntergestuft und es kompiliert. Ich denke, das Problem war, dass die Klasse intern war, was es nicht in 2.0.1 ist, ich frage mich aber warum? Danke, dass du mir geholfen hast :) –

Antwort

0

Das Problem war, dass die AuthenticationOptions Klasse interne gesetzt wurde. Ich habe das Paket Microsft.Owin.Security von 3.0.1 auf 2.0.1 heruntergestuft. Hier ist die Klasse markiert public, so konnte ich ohne Probleme kompilieren.

Dank Dmitry ROTAY