Enums - Compilation error
Hey guys,
I've been trying to compile a file with an Enum type. But for some reason it shows me an weired compile error. What's interesting is; this enum type has 6000+ code lines... I would be grateful if someone can shed some light on this issue. Please drop me an email if you would like to take a look at the code file.
Thanks a lot in advance.
[360 byte] By [
Buddhike] at [2007-12-16]
Thanks for the very quick response. ;-)
I finally found what really matters.
I have a member called System in my enum. I can not apply System.Xml.Serialization.XmlEnumAttribute to this member. It generates a compile error, 'Xml' is not a member of 'VBConsole.MyEnum'. However I can do this in C# without a problem. ;)
This is how my code looks like:
| |
Public Enum MyEnum <System.Xml.Serialization.XmlEnumAttribute(Name:="System")> _ System End Enum |
Cheers!
Hi,
Because there is an enum element named "System" and a namespace "System", the System namespace needs to be qualified with the Global keyword to resolve the conflict. It's a very subtle problem :(. The resulting code looks like:
| |
Public Enum MyEnum <Global.System.Xml.Serialization.XmlEnumAttribute(Name:="System")> _ System End Enum
|
Hope this helps!
Joe
The VB Team
Hi Joe,
Thanks for the answer. However I think the compiler should be able to resolve the namespace name conflicts at this stage. Shouldn't it? C# does it

. Let me know your thoughts... ;-)