Re: Enabling Access to Private Fields

From: Russell B. Eggen (NOreggen_at_gte.netSPAM)
Date: 10/26/03

  • Next message: Michel Gallant: "Re: CryptExport private key only"
    Date: Sun, 26 Oct 2003 10:58:09 -0500
    
    

    Why not add a method to return the value of your private fields? I would
    not bother with methods that could write to them, otherwise, what would be
    the point of making them private? <g>

    -- 
    Russ Eggen
    www.radfusion.com
    "Jeff Benson" <blaster151@hotmail.com> wrote in message
    news:uJAdfi9mDHA.684@TK2MSFTNGP09.phx.gbl...
    Hello,
    I am wondering if it is possible to use declarative security permissions (or
    some other technique) to allow a dynamically synthesized assembly (one that
    I'm compiling on-the-fly from C# code I've built myself at runtime) to
    access private fields on classes in the assembly that's performing the
    dynamic compilation.
    In other words, code in Assembly A wants to dynamically compile a new
    Assembly B (using the System.CodeDom.Compiler namespace) and allow Assembly
    B to access private fields in Assembly A.  (I could probably make them
    "protected" or "internal" if I had to, but would prefer to let them remain
    private.)
    Since I know that Assembly B could access Assembly A's private fields
    through reflection (just much more slowly), it seems to me that it must be
    possible to enable it to access them directly.  I've done some preliminary
    reading about code-level permissions, but haven't found the solution.  Any
    advice or even pointers in the right direction would be tremendously
    appreciated!
    Thanks in advance,
    Jeff Benson
    blaster151@hotmail.com
    

  • Next message: Michel Gallant: "Re: CryptExport private key only"

    Relevant Pages

    • Enabling Access to Private Fields
      ... I am wondering if it is possible to use declarative security permissions (or ... I'm compiling on-the-fly from C# code I've built myself at runtime) to ... B to access private fields in Assembly A. (I could probably make them ...
      (microsoft.public.dotnet.security)
    • Re: Enabling Access to Private Fields
      ... These internal methods would then safely, ... > access private fields on classes in the assembly that's performing the ... > dynamic compilation. ...
      (microsoft.public.dotnet.security)
    • Re: Accesing the private members between the instance of same class
      ... > which defines the private fields it's accessing. ... invoke it once. ... > that methods of a class could only access private fields of the ... For some reason I never thought about class vs. instance in ...
      (comp.object)
    • Re: Enabling Access to Private Fields
      ... They should still be private to everything ... > access private fields on classes in the assembly that's performing the ... > dynamic compilation. ...
      (microsoft.public.dotnet.security)
    • Re: Accesing the private members between the instance of same class
      ... Er, actually, no - it's only treating mainas a method of the class ... which defines the private fields it's accessing. ... methods may access private fields of any instance ... so it's not a matter of "C-based OOPL's". ...
      (comp.object)