Constructorname.classname is inaccessible due to its protection le

A

Andrew

I've got a compilation error. It says:
ConstructorName.ClassName is inaccessible due to its protection level

eg:
I've got a windows form with a button, when clicked it goes into code:

ClassName ABC = new ClassName();
ABC.TMsg(messagename);

Any ideas how to fix this ?
The class ClassName is located in another project in the same solution as
the windowsapplication.

Thanks
Andrew
 
J

Jon Skeet [C# MVP]

Andrew said:
I've got a compilation error. It says:
ConstructorName.ClassName is inaccessible due to its protection level

eg:
I've got a windows form with a button, when clicked it goes into code:

ClassName ABC = new ClassName();
ABC.TMsg(messagename);

Any ideas how to fix this ?
The class ClassName is located in another project in the same solution as
the windowsapplication.

And what's the declared access of the parameterless constructor of
ClassName?
 
R

Rudy Velthuis

Andrew said:
I've got a compilation error. It says:
ConstructorName.ClassName is inaccessible due to its protection level

eg:
I've got a windows form with a button, when clicked it goes into code:

ClassName ABC = new ClassName();
ABC.TMsg(messagename);

Any ideas how to fix this ?
The class ClassName is located in another project in the same
solution as the windowsapplication.

Then one can assume that ClassName() is either private or protected.
Perhaps you are being forced to use another constructor, one with
parameters and public, instead?


--
Rudy Velthuis http://rvelthuis.de

"First you forget names, then you forget faces. Next you forget to
pull your zipper up and finally, you forget to pull it down."
-- George Burns.
 
F

Family Tree Mike

After correcting so it compiles, it seems fine to me. You are not showing a
constructor. Did you drop it in what you posted? You are missing a set of
braces around the contents of the class Classname, so it should look like:

namespace ConstructorName
{ class ClassName
{ public void TMsg ()
{

}
}
}
 
A

Andrew

Hi guys,

I changed the class to:

public class ClassName { }

The error is gone.
cheers
Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top