RedGate 有一个 error reporting tool那说它可以
"Get a complete state of your program when it crashed (not just the stack trace), including the values of variables when the crash happened – without having to go back and forth in inefficient email conversations with the end-user."
我已经为我们的应用程序构建了一个未处理的异常报告工具,但我无法想象它们如何在生产代码中获得比堆栈跟踪信息更多的信息。
有没有人有任何想法?
最佳答案
看起来他们所做的是重写您的程序集并在每个方法中添加一个 try/catch 块(除了您明确排除的那些)。 catch 获取所有局部变量的值。所以如果我有代码:
private int Add(int o1, int o2) {
return o1+o2;
}
它会将其修改为:
private int Add(int o1, int o2) {
int ret = 0;
try {
ret = o1+o2;
}
catch (Exception e) {
SpecialExceptionHandler.HandleException(e, new object[]{o1, o2});
}
return ret;
}
相当棘手......因此,它将在异常发生时显示参数和本地人的值。
关于c# - 异常后C#中局部变量的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3087595/