Saturday, November 17, 2007

Inconsistent accessibility: base class is less accessible than class

I was doing some coding in c#. I had one class but decided to split it up so I could reuse some of the functionality later. So I made a simple shell and started moving pieces into the parent class.

On my first compile I got this message: Inconsistent accessibility: base class is less accessible than class

I am a little rusty with my C# and classes, but it turns out I left off the public keyword on the new class. Adding public fixed that compile error.

16 comments:

  1. Anonymous5:13 PM

    I had this same error, arrrg, that was annoying, i sat there for awhile looking at my controller and DAL and couldnt figure it out. I looked up the error and got your site, thanks for the help :)

    ReplyDelete
  2. Anonymous8:18 AM

    Same here...
    Got the error, started Google, found you within seconds and problem solved XD
    Thanks!

    And now I see some other interesting stuff on your site, so lets have a look at that :D

    ReplyDelete
  3. Same deal as previous posters. Thanks for the help.

    ReplyDelete
  4. Anonymous1:28 AM

    Ah, thanks, me too!

    ReplyDelete
  5. Anonymous6:32 PM

    Thanks. I just assumed classes were public by default.

    assesSaved++;

    ReplyDelete
  6. Anonymous10:06 AM

    I fell into the same trap, thanks for a rapid solution!

    ReplyDelete
  7. Anonymous9:43 AM

    perfect! thanks for the help!

    ReplyDelete
  8. Anonymous9:26 AM

    I just ran into this same problem while working on a lab in the 70-528 MCTS book. When you first bring up the code-behind the first class does not have the public infront of it. Of course, in Visual Studio, the default is Public. I added the public in front of the class in question and boom! It worked.

    ReplyDelete
  9. Anonymous5:45 PM

    You trully saved me!!! Thanks!!

    ReplyDelete
  10. Anonymous3:56 PM

    I'm such a failboat, thanks for the great help

    ReplyDelete
  11. I love you man :D
    Just saved me a really big headache

    ReplyDelete
  12. Anonymous9:32 AM

    I had this error too but the class and instantiation of the class were both declared as public. However, the instantiation was using an enumber as one of the parameters and the enumbers were not declared as public. Made 'em public - jobs a good 'un. Just something else to look out for!

    ReplyDelete
  13. Anonymous8:40 PM

    i had the same error, thanks for the post!

    ReplyDelete
  14. Anonymous7:04 AM

    Same error

    ReplyDelete
  15. Tripped across this five years later. Have the same problem, except that in my case, I'm calling an object class from a class that I'm using to build a list, both are public all the way down and I'm _still_ getting the error.

    Hunting for the solution.....

    Shirley Hicks

    ReplyDelete
  16. Anonymous4:10 AM

    thanx buddie you just saved me :)

    ReplyDelete