Re: BindingFlags.Internal, where is that?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: TEK (trondeirikkolloen_at_hotmail.com)
Date: 11/25/04


Date: Thu, 25 Nov 2004 16:32:42 +0100

Hello

Thanks for the reply.

Futher investigation shows that the problem only shows itself if the
internal member is declared in a base class.

Meaning that using:

And having a base class that declares a property as internal causes the call
below (not actual code) to return null instead of the property.

myType.GetProperty(myObject, "MyProperty", BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Instance)

Changing the property to public or making the call directly on the base
class type makes it return the property.

(I have not tested changing the type to protected or private)

Is this a bug?

Regards, TEK

"Ian Griffiths [C# MVP]" <ian-interact-sw@nospam.nospam> skrev i melding
news:<u3q$ezt0EHA.1408@TK2MSFTNGP10.phx.gbl>...

> "TEK" <trondeirikkolloen@hotmail.com> wrote:

> > But how the heck do I get access to the Internal methods???

> > Specifying BindingFlags.Public | BindingFlags.NonPublic causes the

> > internal methods to not be found.

>

> NonPublic gets you all the non-public members (hence the name). This

> includes internal members.

>

> The documentation neglects to include internal members in its list of what

> constitutes non-public, but in practice, NonPublic gets you all the

> non-public members.

>

> --

> Ian Griffiths - http://www.interact-sw.co.uk/iangblog/

> DevelopMentor - http://www.develop.com/

>

>



Relevant Pages

  • Re: Confused on CodeBehind Partial Classes in 2.0
    ... public partial class _Default: System.Web.UI.Page ... IRequiresSessionState is an interface telling that the Page uses session ... Basically they still have the same base class which is ... It is already assumed since *1.cs already declares the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Confused on CodeBehind Partial Classes in 2.0
    ... public partial class _Default: System.Web.UI.Page ... IRequiresSessionState is an interface telling that the Page uses session ... Basically they still have the same base class which is ... It is already assumed since *1.cs already declares the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: forEach and Casting
    ... There is a single type parameter which serves two roles, 1) constraints returned list elements type to any valid subclass of your base class, and 2) declares a type of Class objects being accepted by the method. ...
    (comp.lang.java.programmer)
  • Newbie on Inheritance, Base classes and derived classes
    ... Base Class: Watch Method SetTime ... Derived Class: DigitalWatch Method ChangeBattery ... is it acceptable to use the base class type to access the SetTime method in ... only digital watches ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Inherit an internal class to a public class
    ... public classes in the second assembly, but Visual Studio can't compile ... The direct base class of a class type shall be ...
    (microsoft.public.dotnet.languages.csharp)