Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Constructorname.classname is inaccessible due to its protection le

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 06 Feb 2008 16:17 GMT
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
Jon Skeet [C# MVP] - 06 Feb 2008 16:20 GMT
> I've got a compilation error. It says:
> ConstructorName.ClassName is inaccessible due to its protection level
[quoted text clipped - 8 lines]
> 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?

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Andrew - 06 Feb 2008 16:37 GMT
namespace ConstructorName
{ class ClassName
    public void TMsg ()   
    {

    }
}

Thanks

> > I've got a compilation error. It says:
> > ConstructorName.ClassName is inaccessible due to its protection level
[quoted text clipped - 11 lines]
> And what's the declared access of the parameterless constructor of
> ClassName?
Family Tree Mike - 06 Feb 2008 16:48 GMT
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 ()   
    {

    }
    }
}

> namespace ConstructorName
> { class ClassName
[quoted text clipped - 21 lines]
> > And what's the declared access of the parameterless constructor of
> > ClassName?
Rudy Velthuis - 06 Feb 2008 16:37 GMT
> I've got a compilation error. It says:
> ConstructorName.ClassName is inaccessible due to its protection level
[quoted text clipped - 8 lines]
> 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?

Signature

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.

Andrew - 06 Feb 2008 16:59 GMT
Hi guys,

I changed the class to:

public class ClassName { }

The error is gone.
cheers
Andrew

> > I've got a compilation error. It says:
> > ConstructorName.ClassName is inaccessible due to its protection level
[quoted text clipped - 12 lines]
> Perhaps you are being forced to use another constructor, one with
> parameters and public, instead?
Rudy Velthuis - 06 Feb 2008 17:10 GMT
> Hi guys,
>
> I changed the class to:
>
> public class ClassName { }

YAY!
Signature

Rudy Velthuis        http://rvelthuis.de

"War is fear cloaked in courage." -- General William Westmoreland


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.