How to Trace all local variables when an exception occurs

前端 未结 4 1498
面向向阳花
面向向阳花 2020-12-28 09:27

any generic way to trace/log values of all local variables when an exception occurs in a method? (in C# 3)

4条回答
  •  余生分开走
    2020-12-28 09:55

    You could do a memory dump of the process since that captures both the heaps and the stacks, but since you tagged the question as logging, I assume that is not what you're looking for.

    However, you can reduce the need for this information by making sure your methods are always small and to the point. That will yield much more useful stack traces and it will limit the number of locals to inspect.

提交回复
热议问题