Re: Having problem getting private members using reflection.



Private members from the concrete class or the base class? IIRC, there's one last bit of detail where private base class members are inaccessible via reflection on the derived type. You have to walk up to the Type.BaseType to fetch privates. Perhaps this is the problem?

-Brock
DevelopMentor
http://staff.develop.com/ballen

I am using the BindingFlags that you indicated, and I still cannot get
private members.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Brock Allen" <ballen@xxxxxxxxxxxxxxxxx> wrote in message
news:b8743b113a34d8c797ad5d59f25a@xxxxxxxxxxxxxxxxxxxxxxx
You need to use the overload that accepts a BindingFlags with this

bitmask:

BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance

The simple version of GetMembers only returns the public ones (and
maybe internal and protected too. I can't remember exactly).

As for the ReflectionPermission, if you're running in FullTrust you
have the permission. This security check is so mobile downloaded code
won't be able to scrape thru all private members changing their
values. That would be a problem.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an ASP.NET application that is calling a custom class that is
trying to parse all of the members of my Page object using
Type.GetMembers().  The problem that I am having is that private
members are not returned.  I did some digging and the MSDN
documentation states that the caller must have ReflectionPermission
in order to get the private members of a class.  I am a little
unfamiliar with this stipulation.  I have checked the docs on
ReflectionPermission, but the examples do not make much sense.
Could someone please clarify on what I need to do in order for my
code to be able to parse private members of my Page using
reflection?

EmailID = varnk
Domain = Diebold.com
-----------------------------------


.



Relevant Pages

  • Re: Having problem getting private members using reflection.
    ... Apparently passing 'this' will not work ... "Ken Varn" wrote in message ... did some digging and the MSDN documentation states that the caller must have ReflectionPermission in order to get the private members of a class. ... ReflectionPermission, but the examples do not make much sense. ...
    (microsoft.public.dotnet.framework.aspnet)
  • private field is never assigned ; force comiler to stop complaining?
    ... know if there is a more relevant group. ... I have a series of private members in my class, ... reflection in a base class. ... basis for supressing or eliminating the compiler warning. ...
    (microsoft.public.dotnet.general)
  • Re: private instance variable of derived class not always returned by base class getter?
    ... combination of private instance variables than can be accessed through ... getters declared in the base class. ... Private members can only be seen inside the ... The getters and setters of the base-class can only ...
    (comp.lang.java.help)
  • Re: OO Design question
    ... Today your base class *only* has common data. ... Pure data-only objects are well-expressed using structs. ... instantiating your structs as private members of the base class, ... also happens to be far more flexible than using multiple levels of ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: When should we use the single inheritance v.s private members
    ... In case of single inheritance u can call functions of base class ... I am sending u the code so u can understand the logic when use single inheritance or when use private members as containers.. ... int main(int argc, char* argv[]) ...
    (microsoft.public.dotnet.languages.vc)