Get all references and values ​​from the stack

I need to get information from the current context at runtime. Therefore, they are interested in receiving information about local residents and registering it. The context will change dynamically, so I cannot store information from exact variables. I can get information from this.GetType () and get all member values, but sometimes this is not enough for my tracking of a floating error.

How can I get all references and C # values ​​from the current stack at runtime and get their types and values ​​(like the Locals window in visual studio)?

+4
source share
1 answer

Does this help you:

MethodBase method = MethodBase.GetCurrentMethod();
MethodBody methodBody = method.GetMethodBody();
IEnumerable<LocalVariableInfo> variableInfos = methodBody.LocalVariables;
+2
source

Source: https://habr.com/ru/post/1624440/


All Articles