BUG: "Cannot refer to an instance member of a class" error message occurs when you have an assembly that uses an Enum and Class method of the same name (814602)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
SYMPTOMSWhen you have an assembly that uses an Enum method and a Class method and both methods have the same name, you may receive the
following error message: Cannot refer to an instance
member of a class from within a shared method or shared member initializer
without an explicit instance of the class. CAUSEYou receive this error message when you refer to Enum in shared methods of the Class. The compiler incorrectly binds to the instance method of the Class. The compiler is supposed to bind to the Enum.WORKAROUNDTo work around this problem, refer to Enum with a fully-qualified name, as in the following
example: Namespace.Enum.MemberName STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.REFERENCES
For more information about shared keywords in Visual Basic .NET, click the following article number to view the article in the Microsoft Knowledge Base:
308371
How to create and use shared members by using Visual Basic .NET
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbvs2002sp1sweep kberrmsg kbCompiler kbbug KB814602 kbAudDeveloper |
---|
|