I think there is some trouble in Reflection land. Can someone else test this and see if they get the same result? I'll post just the code so nobody has to convert from 2002 or 2003.
VB Code:
Public Class Test Private _Name As String Public ID As Integer = 0 Public ReadOnly Property Name() As String Get Return _Name End Get End Property Public Sub Test() Dim bf As Reflection.BindingFlags = Reflection.BindingFlags.Public Dim fi As Reflection.FieldInfo For Each fi In Me.GetType.GetFields(bf) MsgBox(fi.Name, , "Worked WITH flags") Next For Each fi In Me.GetType.GetFields MsgBox(fi.Name, , "Worked withOUT flags") Next End Sub End Class 'the test in a form on a button click or whatever Dim t As New Test t.Test()
I only get one message box and there should be two. It seems that the GetFields, GetProperties, GetMembers methods used in reflection only work when no flags are passed to them. If you pass any BindingFlags in then it returns nothing all the time even though its oberloaded to take such.


Reply With Quote
. I'm using VS.NET 2003 .

