Reflection problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scoffer

    #1

    Reflection problem

    Hi,

    i'm trying to access a property value in this way:

    PropertyInfo pi = myObject.GetTyp e().GetProperty (myPropName);

    I'm sure that the object myObject have the myPropName property, but the pi
    variable result nothing.

    Can you help me??


  • Ahmed

    #2
    Re: Reflection problem

    Hi,

    If you know the type of the object or the super class/interface of a
    collection of objects I would do the following:

    If typeof myobject is objectType then

    propertyinfo pi = ctype(myObject, objectType).myP ropName

    end if

    I hope that helps.

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Reflection problem

      "scoffer" <scoffer@email. it> schrieb:[color=blue]
      > i'm trying to access a property value in this way:
      >
      > PropertyInfo pi = myObject.GetTyp e().GetProperty (myPropName);
      >
      > I'm sure that the object myObject have the myPropName property, but the pi
      > variable result nothing.[/color]

      Check out the overloaded verisons of 'GetProperty', especially those which
      accept 'BindingFlags'. Specify 'BindingFlags.I nstance' and appropriate
      binding flags for the accessibility of the property.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      Working...