Coder Perfect

Accessibility is inconsistent: parameter types are less accessible than methods.


I’m trying to transmit an object between two forms (essentially, a reference to the presently logged on user). In the login form, I currently have something along these lines:

private ACTInterface oActInterface;

public void button1_Click(object sender, EventArgs e)
        oActInterface = new ACTInterface(@"\\actserver\Database\Premier.pad",this.textUser.Text,this.textPass.Text);

        if (oActInterface.checkLoggedIn())
            //user has authed against ACT, so we can carry on
            clients oClientForm = new clients(oActInterface);

I have the following information on the next form (clients):

public partial class clients : Form
    private ACTInterface oActInt {get; set;}

    public clients(ACTInterface _oActInt)

As a result of this, I receive:

Error   1   Inconsistent accessibility: 
parameter type 'support.ACTInterface' is less accessible than method    
c:\work\net\backup\support\support\clients.cs   20  16  support

I’m not sure what the issue is – both fields are private and are accessed through the form’s relevant public method. Googling isn’t much help because it just shows one element as public and the other as private, which isn’t the situation here.

Anybody help?

Asked by dodgrile

Solution #1

Although the constructor of the public class clients is public, it has a private parameter of type ACTInterface (is it nested in a class?). You’re not going to be able to do it. You must make ACTInterface as user-friendly as clients.

Answered by jason

Solution #2

Publicize the class.

class NewClass


corresponds to:

internal class NewClass


As a result, the class must be open to the public.

Answered by Nisha

Solution #3

It appears that the type ACTInterface is not public, but rather uses either internal (if it is top-level) or private as its default accessibility (if it is nested in another type).

Adding the public modifier to the type would solve the problem.

If that’s what you want, another option is to make both the type and the method internal.

The problem isn’t with the field’s accessibility (oActInterface), but with the type ACTInterface itself.

Answered by Marc Gravell

Solution #4

What is the type support’s accessibility? ACTInterface. It is not public, according to the inaccuracy.

You can’t disclose a public method signature if some of the signature’s parameter types aren’t public. It would be impossible to call the method from the outside since the caller would be unable to assemble the needed parameters.

If you make a contribution. This mistake will be removed by using the ACTInterface public. Alternately, if possible, reduce the form method’s accessibility.

Answered by James Gaunt

Solution #5

parameter type 'support.ACTInterface' is less accessible than method    

The problem states that’support.ACTInterface’ is less accessible since the interface is set to private; at the very least, make it internal or public.

Answered by Harrish Selvarajah

Post is based on