Results 1 to 3 of 3

Thread: question about System.Reflection

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    question about System.Reflection

    I have a COM object (which I did not create), and when I use the method Type.GetProperties(), it returns an array of PropertyInfo, but the thing is, it is returning a bunch of properties that don't usually show up through intellisense when accessing the properties directly (ie. comObject->property1). Is there a way to make it so that the only PropertyInfo that is returned are the ones that I see in when using intellisense? I've tried doing this:

    Code:
    Type.GetProperties(BindingFlags.Public)
    But it ends up returning 0 properties. Any ideas? Thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: question about System.Reflection

    You should play around with various combinations of BindingFlags values. You can combine them with a bitwise Or.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: question about System.Reflection

    You'll need to determine whether you want instance methods include and/or static methods included. Since you've specific neither, you won't be getting any results. So, like John mentioned, you'll have to take a look at the BindingFlags that you want. It is quite likely that you'll want the Instance flag combined with your Public flag. Your flags would look like this:
    Code:
    BindingFlags flags = BindingFlags.Public | 
                         BindingFlags.Instance;
    // = 0001 0100
    // = 20
    The Type.GetProperties method you used will return all public instance or static methods.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width