简体   繁体   English

.NET生产调试

[英].NET Production Debugging

I've had a Windows app in production for a while now, and have it set up to send us error reports when it throws exceptions. 我已经在生产中使用了一段时间的Windows应用程序,并设置为在它抛出异常时向我们发送错误报告。 Most of these are fairly descriptive and help me find the problem very quickly (I use the MS Application Exception Block). 其中大部分都是相当描述性的,可以帮助我快速找到问题(我使用的是MS Application Exception Block)。

On a few occasions I have reports that are issues that I can't reproduce, and seem to only happen on a few client machines. 有几次,我的报告是我无法重现的问题,似乎只发生在一些客户端机器上。

I don't have physical access to these client machines, what are some strategies I can use for debugging? 我没有物理访问这些客户端机器,我可以使用哪些策略进行调试? Would it be better to build some tracing into the code, or are there some other alternatives? 在代码中构建一些跟踪是否会更好,还是有其他替代方案?

Thank you. 谢谢。

Edit: I should have been more clear: The error reports that I get do have the stack trace, but since it's production code, it doesn't indicate the exact line that caused the exception, just the method in which it was thrown. 编辑:我应该更清楚:错误报告我得到了堆栈跟踪,但由于它是生产代码,它并不表示导致异常的确切行,只是它抛出的方法。

You are on the right track. 你走在正确的轨道上。 You need to create a tracking module which logs actions/exceptions locally. 您需要创建一个在本地记录操作/异常的跟踪模块。

You can then have a button or a menu option that the user can click to either automatically email you this information the moment the issue occurs, or they can have the option to get hold of the file so that they can transfer it to you in any other way. 然后,您可以使用一个按钮或菜单选项,用户可以单击该选项,以便在问题发生时自动通过电子邮件向您发送此信息,或者他们可以选择获取文件以便他们可以将其传输给您另一种方式。

You can even build-in a diagnostics code to run an integrity check on the system and sends you a report (maybe it runs all your unit tests to see if they work on that system). 您甚至可以内置诊断代码以在系统上运行完整性检查并向您发送报告(可能它会运行所有单元测试以查看它们是否在该系统上运行)。

One option is to generate a (mini-)dump file as close to the point where the exception is thrown as possible. 一种选择是生成(小)转储文件,尽可能接近抛出异常的点。 This article talks about how to do this from managed code. 本文讨论如何从托管代码执行此操作。

You could then load the dump file into Visual Studio or WinDbg and examine it with the aid of SOS 然后,您可以将转储文件加载到Visual Studio或WinDbg中,并借助SOS进行检查

我总是使用Jeff的这个模块来处理未处理的异常,给我发送一封带有stacktrace等的电子邮件。

Smart Inspect from Gurock Software has come in handy many times for me. Gurock Software的 Smart Inspect已经为我多次派上用场了。 It is very easy to put into a .NET application and gives you extremely powerful control when analyzing log files. 在分析日志文件时,很容易将其放入.NET应用程序并为您提供极其强大的控制。 It has log levels that allow you to turn off certain functionality except in certain cases so you don't lose performance. 它具有日志级别,允许您关闭某些功能,除非在某些情况下,所以您不会失去性能。

They even have server software that your software can connect to to save logs when you do not have full access to the machines. 他们甚至拥有您的软件可以连接的服务器软件,以便在您无法完全访问计算机时保存日志。 For example, you could have a server running at www.yourdomain.com. 例如,您可以在www.yourdomain.com上运行服务器。 Your software would have a configuration option to turn on debugging. 您的软件将有一个配置选项来打开调试。 Smart Inspect would be configured to send the log data to your server (And optionally to a local file) so that you could get live logging no matter where the software is being run. Smart Inspect将配置为将日志数据发送到您的服务器(以及可选地发送到本地文件),以便无论软件在何处运行,您都可以获得实时日志记录。

Smart Inspect is very easy to configure and has many features that you can use to help. Smart Inspect非常易于配置,并且具有许多可用于帮助的功能。 I've use it to debug high impact multi-threaded server applications on the fly without taking down the machines. 我已经使用它来动态调试高影响力的多线程服务器应用程序而无需关闭机器。 It has all the hooks to keep track of different processes, threads and machines. 它具有跟踪不同进程,线程和机器的所有钩子。

I'd make use of the event log. 我会使用事件日志。 Take a look here: 看看这里:

http://support.microsoft.com/kb/307024 http://support.microsoft.com/kb/307024

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM