Class is inaccessible due to its protection level

Posted on 2007-10-11
Last Modified: 2008-01-09
Ok, I have created this class:

using System.Security.Principal;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.EnterpriseLibrary.Security.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Security.Instrumentation;
using Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation;
using System.Collections.Generic;

namespace Microsoft.Practices.EnterpriseLibrary.Security
    /// <summary>
    /// implementation of the <see cref="IVAuthorizationProvider"/> interface.
    /// </summary>
    public class VAuthorizationProvider : IVAuthorizationProvider, IInstrumentationEventProvider
        AuthorizationProviderInstrumentationProvider instrumentationProvider;
.. rest of class members here

In a console project, in a class I created in order to test a method call for that class I tried to create the console test like this:

namespace TestSandBox
    class VAuthorizationProviderTesting
        static void Main(string[] args)
            List<string> rightToCheck = null;


            VAuthorizationProvider provider = new VAuthorizationProvider();
            IPrincipal principal = new GenericPrincipal(new GenericIdentity("Don"), new string[] { "Manager" });

            provider.Authorize(principal, rightToCheck);

For the line VAuthorizationProvider provider = new VAuthorizationProvider();

I get the error "Microsoft.Practices.EnterpriseLibrary.Security.VAuthorizationProvider.VAuthorizationProvider()' is inaccessible due to its protection level
Question by:dba123
    LVL 29

    Accepted Solution

    can u give the construcotrs of VAuthorizationProvider
    LVL 16

    Assisted Solution

    Do yoyu have a public constructor?
    LVL 11

    Expert Comment

    by:Mihai Stancescu
    You must have the main constructor of that class public, should be something like this:

    public VAuthorizationProvider()
     //...constructor login here

    Hope this helps!

    LVL 26

    Expert Comment

    by:Anurag Thakur
    The error can come when you can not create member of the class i.e. the default constructor (as in this case) is private
    private VAuthorizationProvider ()
    or it is protected

    Hope this helps
    LVL 16

    Expert Comment

    So that's three people who have pointed out that they probably needs a public constructor, do you think they are listening?
    LVL 1

    Author Comment

    nah, I decided to be cool and use a protected.  Ah!  thanks.  Ok, so I had copied code from another abstract class.  Why did I do this, cause I was assigned in my group to create a custom AuthorizationProvider.cs.  Well, I wasn't sure how so I created a new class, copied the code and then tweaked it to make it "custom" in my n ew class as well as created a new interface.  I guess I coul dhave just inherited the initial abstract class in my new class.   Not sure which way to go.

    So since I had pasted the code, the constructor was protected.  I see now.  Thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now