Can someone explain why this VB.NET code fails to compile?
Imports System.ComponentModel
Public Enum Mode
Mode1
Mode2
End Enum
Public Class Class1
<DefaultValue(Mode.Mode1)> _
Dim Mode As Mode = Mode.Mode1
End Class
The resulting compiler error is "error BC30469: Reference to a non-shared member requires an object reference." It seems to be some sort of scoping confusion between the field and the enum (if you rename the field it works).
We're encountering this while adding a web reference to our web service (so the classes are auto-generated). It only fails in VB.NET - the equivalent code in C# works just fine.