通过.NET桌面应用程序发送错误日志
最近,我们的客户遇到了意想不到的崩溃。我们已经在他们的本地计算机上记录了错误。是否有一种机制可以让他们在应用程序崩溃或发生意外行为时以某种方式“发送错误日志”?
换句话说,我如何知道应用程序冻结、挂起或崩溃,以便我可以发送某些内容,并覆盖正常的“未响应”Windows 消息?
Lately our customers are experiencing unexpected crashes. We are already logging the errors on their local machines. Is there a mechanism to enable them to "send error log" somehow when the application crashes or when unexpected behavior takes place?
In other word how do I know that the application freezed or hung or crashed so I can send something, and override the normal "not responding" windows message?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果它挂起,您无能为力,但如果它崩溃了,您可能可以使用 UnhandledExceptionEventHandler。
您可以通过检查应用程序启动时是否正确关闭并向日志写入“关闭”消息来处理挂起,如果没有,您可以询问用户是否要将日志发送到你。
I don't think there's much you can do if it's hung but if it crashes you might be able to catch some of those crashes with the UnhandledExceptionEventHandler.
You could possibly handle the hangs by checking when the application starts up if it previously shut down correctly and wrote a "shutting down" message to the log, and if it didn't you could ask the user if they want to send the log to you.
过去,我很幸运地使用如下代码将异常记录到 Web 服务(只要允许客户端注销到互联网)。这是为了记录您尚未捕获的任何内容。如果您在发布模式下编译应用程序,但还包含 pdb 文件,您将获得带有行号的堆栈跟踪。
您还应该记录程序集的版本,以了解哪个版本的应用程序给您带来错误。
In the past I've had luck with logging exceptions to a webservice (as long as the client are allowed to log out to the internet) with code like the one below. This is for logging anything you're not already catching. If you compile your application in release mode but also include the pdb files, you will get a stacktrace with line numbers.
You should also log the version of your assembly to know what version of the application is giving you errors.