GetPropertyValue (In ActiveOtherStuff) chokes on Prop.GetValue(target) if ....

GetPropertyValue (In ActiveOtherStuff) chokes on Prop.GetValue(target) if ....

Old forum URL: forums.lhotka.net/forums/t/1244.aspx


Jav posted on Monday, September 18, 2006

I made a property's access 'Friend' because I wanted it to be accessed through its containing parent object - the idea was to stop me from accessing it directly because of some issues.

In ActiveOtherStuff, the method GetPropertyValue is as follows:

Public Shared Function GetPropertyValue(ByVal target As Object, ByVal propertyName As String) As Object
      
Dim prop As PropertyDescriptor = TypeDescriptor.GetProperties(target.GetType)(propertyName)
      
Return prop.GetValue(target)
End Function

While the target argument is perfectly sound on entry into the Method, the code chokes when the line Prop.GetValue(target) is called with an error saying that target is Null.  The error disappeared when I changed the Property's access back to Public.

Jav

Copyright (c) Marimer LLC