mercredi 11 décembre 2019

Is it possible to use reflection for a private static variable in a DLL?

I'm trying to change the value of a singleton in a DLL for a project, a fix is coming in 2 months, but until then I want to use reflexion to change some settings into that singleton to keep working. I have access to the DLL's code, so I know the private members.

each time I try to use reflexion on the DLL class, I get a null value for the field. Am I missing something, or is reflexion simply impossible in between DLL?

var field = typeof(SingletonClass).GetField("_Instance", BindingFlags.NonPublic | BindingFlags.Static);
var customSettings = new SingletonClass();
// ...

field.SetValue(null, customSettings);




Aucun commentaire:

Enregistrer un commentaire