gpt4 book ai didi

c# - .Net Windows 服务抛出 EventType clr20r3 system.data.sqlclient.sql 错误

转载 作者:行者123 更新时间:2023-11-30 15:11:06 24 4
gpt4 key购买 nike

我有一个 .Net/c# 2.0 windows 服务。入口点包含在一个 try catch block 中,该 block 通知我出现问题并允许服务继续正常运行,但当我查看服务器的应用程序事件日志时,我看到许多导致服务终止的“EventType clr20r3”错误不料。 catch block 有一个“catch (Exception ex)”,不会重新抛出异常。

每个 sql 命令都是“CommandType.StoredProcedure”类型,并使用 SqlDataReader 执行。这些 sproc 调用在 99% 的时间内都能正常运行,并且都经过了全面的单元测试、概要分析和 QA。我另外将这些调用包装在 try catch block 中只是为了确定并且仍然遇到这些未处理的异常。

这仅适用于我们的生产环境,无法在我们的开发或暂存环境中复制(即使在重负载下)。

为什么我的错误处理没有捕捉到这个特定的错误?无论如何,是否可以捕获有关问题根本原因的更多详细信息?

这是事件日志的示例:

EventType clr20r3, P1 RDC.OrderProcessorService, 
P2 1.0.0.0,
P3 4ae6a0d0,
P4 system.data,
P5 2.0.0.0, P6 4889deaf,
P7 2490,
P8 2c,
P9 system.data.sqlclient.sql,
P10 NIL.

另外

The Order Processor service terminated unexpectedly.  
It has done this 1 time(s).
The following corrective action will be taken in 60000 milliseconds:
Restart the service.

最佳答案

来自评论的回答。很高兴有帮助。 :)

Have you tried adding an AppDomain.UnhandledException event handler? msdn.microsoft.com/en-us/library/… Pretty much the problem is you have an unhandled SQL exception somewhere in your code.

Not necessarily, but without seeing your code or the libraries you are using, there is no way to know if the exception is occuring in a different thread, in a 3rd party library, etc... By wiring an AppDomain.UnhandledException handler, you should at least by able to log the exception details and figure out where your problem point is. Just cast the EventArg to ((Exception)e.ExceptionObject).Message and you should at least have a better idea where your unhandled exception is.

关于c# - .Net Windows 服务抛出 EventType clr20r3 system.data.sqlclient.sql 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2739107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com