J
Jeff Benson
Hello,
I am wondering if it is possible to create a dynamically synthesized
assembly (one that I'm compiling on-the-fly from C# code I've strung
together myself at runtime) using the System.CodeDom.Compiler namespace, and
give the resulting assembly identical permissions as those of the current,
running assembly (or even be given the ability to access fields declared as
"internal", etc.)
Specifically, code in Assembly A wants to dynamically compile a new Assembly
B (using the System.CodeDom.Compiler namespace) and allow the just-compiled
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.)
I'm trying to fabricate data-mapping objects on the fly, based on metadata,
and it's working perfectly except for the fact that the new objects don't
have permission to set (or read) the private fields on the business objects
they're supposed to be mapping to a database. If I made all of these fields
public, the technique would work perfectly, but I'd prefer not to break
encapsulation in that way.
Any help would be tremendously, hugely appreciated!
Jeff Benson
(e-mail address removed)
I am wondering if it is possible to create a dynamically synthesized
assembly (one that I'm compiling on-the-fly from C# code I've strung
together myself at runtime) using the System.CodeDom.Compiler namespace, and
give the resulting assembly identical permissions as those of the current,
running assembly (or even be given the ability to access fields declared as
"internal", etc.)
Specifically, code in Assembly A wants to dynamically compile a new Assembly
B (using the System.CodeDom.Compiler namespace) and allow the just-compiled
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.)
I'm trying to fabricate data-mapping objects on the fly, based on metadata,
and it's working perfectly except for the fact that the new objects don't
have permission to set (or read) the private fields on the business objects
they're supposed to be mapping to a database. If I made all of these fields
public, the technique would work perfectly, but I'd prefer not to break
encapsulation in that way.
Any help would be tremendously, hugely appreciated!
Jeff Benson
(e-mail address removed)