A
adiel_g
I am trying to set a value on a structure object dynamically using
InvokeMember. After I call InvokeMember, the value on the Admin flag
does not get updated. Here is the following sample code to reproduce
the behavior:
Public Class clsTest
Public Structure userGroupStruc
Dim User As Boolean ' User Account
Dim Admin As Boolean ' Administration Account
End Structure
Public objUserGroup As userGroupStruc
Public Sub setupAccess()
Dim currentGroup As String
currentGroup = "Admin" ' For the test, lets set Admin to
True
objUserGroup.GetType().InvokeMember(currentGroup,
Reflection.BindingFlags.SetField, Nothing, objUserGroup, New Object()
{True})
End Sub
End Class
To test the behavior, simple create the class and call the setupAccess
method:
Dim objTest As New clsTest
objTest.setupAccess()
If you then take a look at the value of objUserGroup.Admin, it is
still false! (Even though we called InvokeMember and set it to true.)
I must be setting up the InvokeMember wrong but have been breaking my
head on this one... I would appreciate your help on this one.
Thanks Before Hand,
Adiel
InvokeMember. After I call InvokeMember, the value on the Admin flag
does not get updated. Here is the following sample code to reproduce
the behavior:
Public Class clsTest
Public Structure userGroupStruc
Dim User As Boolean ' User Account
Dim Admin As Boolean ' Administration Account
End Structure
Public objUserGroup As userGroupStruc
Public Sub setupAccess()
Dim currentGroup As String
currentGroup = "Admin" ' For the test, lets set Admin to
True
objUserGroup.GetType().InvokeMember(currentGroup,
Reflection.BindingFlags.SetField, Nothing, objUserGroup, New Object()
{True})
End Sub
End Class
To test the behavior, simple create the class and call the setupAccess
method:
Dim objTest As New clsTest
objTest.setupAccess()
If you then take a look at the value of objUserGroup.Admin, it is
still false! (Even though we called InvokeMember and set it to true.)
I must be setting up the InvokeMember wrong but have been breaking my
head on this one... I would appreciate your help on this one.
Thanks Before Hand,
Adiel