Re: Having problem getting private members using reflection.
- From: Brock Allen <ballen@xxxxxxxxxxxxxxxxx>
- Date: Wed, 05 Oct 2005 08:20:14 -0700
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@xxxxxxxxxxxxxxxxxxxxxxxYou 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/ballenI 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 -----------------------------------
.
- Follow-Ups:
- Re: Having problem getting private members using reflection.
- From: Ken Varn
- Re: Having problem getting private members using reflection.
- Prev by Date: Re: ThreadAbortException when using Trace
- Next by Date: Re: generated jscript link and urlencode
- Previous by thread: Re: ThreadAbortException when using Trace
- Next by thread: Re: Having problem getting private members using reflection.
- Index(es):
Relevant Pages
|