lundi 26 juin 2017

Loading constants in a different AppDomain

I want to load some constants of an assembly without loading it in my principal AppDomain.

Original code was :

Assembly = Assembly.Load("MyAssembly");
Type myType = assembly.GetType("MyType");
object o = myType.GetType().GetProperty("myProperty").GetValue(null, null);

Knowing that myProperty is initialized with a constant. I can either access it by the property or the constant.

The Type isn't marked serializable (and I can remove the static but nothing more) so I cannot access it by AppDomain.CreateInstanceAndUnwrap but that's precisely what I want to do : loading the constant without getting the assembly to fill my AppDomain.

How can I do that ?





Aucun commentaire:

Enregistrer un commentaire