Type.FullName returns malformed name
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

George
I declared an enumeration inside an interface. Trying to use reflection to
find the FullName of the enumeration type produces

"WindowsApplication1.IGeorge+GeorgeConstants"

rather than

"WindowsApplication1.IGeorge.GeorgeConstants"

as I (and the rest of the framework) would expect.

My code is as follows (start a new VB Windows app, add the Interface and the
call to Msgbox into the Form_Load, hit F5):

Public Interface IGeorge
Enum GeorgeConstants
GeorgeConstant1
GeorgeConstant2
GeorgeConstant3
End Enum
End Interface

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
:
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MsgBox(GetType(IGeorge.GeorgeConstants).FullName)
End Sub

End Class

George.

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "George" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

Notice that the type 'GeorgeConstants' is defined /inside/ 'IGeorge', so
it's a nested type. Nested types are indicated with a "+" separator
instead of ".". If you don't want 'GeorgeConstants' to be a nested
type, take its code and place it somewhere outside your interface.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
George,
As the others suggest + is the delimiter for nested types.

For details see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassassemblyqualifiednametopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconSpecifyingFullyQualifiedTypeNames.asp

Hope this helps
Jay

"George" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
George
Thanks, I've now read up about the (many) delimiters. I never realised there
were so many. Makes sense once you know why though.

The problem occurred in a third party grid product that was bound to a
DataTable containing a field of an Enum type. When the grid tried to convert
its display value to the underlying enum type it used reflection to get the
target type and then some sort of conversion procedure which doesn't
understand the '+'. I've changed my code to use the underlying primitive
type in the DataTable (Int32 for Enum types), pending a fix from the third
party.

George

"Jay B. Harlow [MVP - Outlook]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Mattias Sjögren
[Original message clipped]

Reflection uses + as the delimiter between a nested class and its
encloser. Nothing wrong there.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
 
 
System.Data.DataTable
System.EventArgs
System.Object
System.Windows.Forms.Form




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com