mercredi 6 mai 2020

Reflection. Why does my line return null in the code, but works fine in the debugger?

I have a line of code, an assignment, that assigns null when run, but when I visit in the debugger, the line does just what I want. The line is...

object instance = typeof(SqlEditorPackage).GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

In the below screenshot, you can see the local variable instance is null, whereas in the watch, the same line gives me a populated object. What is going on?

enter image description here





Aucun commentaire:

Enregistrer un commentaire