windows 如何调试记录在事件查看器中的 .NET 错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2554055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:12:40  来源:igfitidea点击:

How to debug .NET error logged in an Event Viewer?

.netwindowsdebugginglogging

提问by PaN1C_Showt1Me

Hi I found out that my application causes some errors which are logged in an Event log.

嗨,我发现我的应用程序导致了一些记录在事件日志中的错误。

It states:

它指出:

NET Runtime 2.0 Error 

    EventType clr20r3, P1 *****.exe, P2 1.0.0.0, P3 4b2a572f, P4 system.web.services, P5 2.0.0.0, P6 4889df18, P7 bc, P8 65, P9 system.net.webexception, P10 NIL.

How can I find out what's going on? I've tried that app locally and everything works fine.

我怎样才能知道发生了什么?我在本地尝试过该应用程序,一切正常。

采纳答案by Andy Shellam

Can you describe more about the type of application it is? What it's doing, is it interactive or non-interactive?

你能详细描述一下它是什么类型的应用程序吗?它在做什么,是交互式的还是非交互式的?

The actual error is system.net.webexception- which is some form of problem communicating with a web-page or web-service. This in itself suggests it might an intermittent error if it works fine when you try it.

实际错误是system.net.webexception- 这是与网页或网络服务通信的某种形式的问题。这本身就表明,如果它在您尝试时运行良好,则它可能会出现间歇性错误。

Either that or something is misconfigured when it's running remotely - something different to your environment. For example, do you use an internal DNS entry that's not available when the application is run remotely?

当它远程运行时,要么配置错误,要么配置错误 - 与您的环境不同。例如,您是否使用远程运行应用程序时不可用的内部 DNS 条目?

You will want to catch all exceptions in your application (like an overall try { } catch { }in your mainmethod) and log the exceptions to a file, or get it to e-mail them to yourself, so you can see in more detail what's occuring.

你会想抓住你的应用程序的所有异常(如总try { } catch { }在你的main方法),并记录异常到一个文件,或得到它的电子邮件他们自己,这样你就可以更详细地什么发生的历史看。

回答by Hans Passant

Your app crashed on an unhandled exception. The Watson log won't be good enough to find the cause. Write an event handler for the AppDomain.CurrentDomain.UnhandledException event, have it write e.ExceptionObject.ToString() to the event log so you'll get a good stack trace that shows you why and where it bombed.

您的应用程序因未处理的异常而崩溃。Watson 日志不足以找到原因。为 AppDomain.CurrentDomain.UnhandledException 事件编写一个事件处理程序,让它将 e.ExceptionObject.ToString() 写入事件日志,这样您将获得一个很好的堆栈跟踪,显示它为什么以及在哪里爆炸。

回答by Naveen

Here is the simple explanation from your event log entry

这是您的事件日志条目的简单解释

P4 system.web.services -  module that was throwing the exception 
P9 system.net.webexception  - Exception Type
P8 65 - IL Offset where the exception was thrown

These are Watson bucket for getting the call-stack of the exception. From .NET 2.0 onwards Watson reports have this information.

这些是用于获取异常调用堆栈的 Watson 存储桶。从 .NET 2.0 开始,Watson 报告包含此信息。

Here is the MSDN articlefor above explanation.

这是上述解释的MSDN 文章

回答by TLiebe

It looks like an unhandled exception. If it's being generated in an web application or service you can try putting an global exception handler in your global.asax file. See herefor an example. You can trap the error and output some better information to the event log.

它看起来像一个未处理的异常。如果它是在 Web 应用程序或服务中生成的,您可以尝试在 global.asax 文件中放置一个全局异常处理程序。有关示例,请参见此处。您可以捕获错误并将一些更好的信息输出到事件日志。