Reputation: 6150
I'm working with a COM library that can throw a lot of error number codes, and to help with that I have a class full of int
constants that map each error for example: int ERR_FILE_NOT_FOUND = 1300
means if a function returns 1300 then a file not found error occurred. Either way, I have about 300 variables, and everything was working nicely since I added them in a another partial class of my MainClass
object. However, I wanted to encapsulate everything correctly and moved all the constants from my MainClass
into a new class called ErrorLib
but I got an error saying:
member cannot be accessed with an instance reference qualify it with a type name instead
I've read up a bit about problems with constants, so I removed the constant keyword but the error still happened. I tried doing a MainClass : ErrorLib
to inherit from it all the variables but it still won't detect them. I tried instantiating ErrorLib
as a err
variable and then using err.VariableName
to access them but still no luck. What am I doing wrong?
Edit: Thanks guys. The fix was something so obvious. You answered this SECONDS withing me posting this, to the point StackOverflow won't let me select as correct answer if 11 minutes don't pass. Thanks for the ideas tough.
Upvotes: 1
Views: 669
Reputation: 32566
member cannot be accessed with an instance reference qualify it with a type name instead
As the error message suggests, try
ErrorLib.ERR_FILE_NOT_FOUND
Upvotes: 1