gpt4 book ai didi

crash - 应用程序崩溃时,没有致命异常的迹象NLog版本2 |紧凑框架3.5

转载 作者:行者123 更新时间:2023-12-03 17:41:17 25 4
gpt4 key购买 nike

我有一个.Net Compact Framework 3.5应用程序,该应用程序使用Nlog 2.0版记录信息,错误和致命异常。大多数情况下,日志记录会按预期运行,并在崩溃前记录致命异常。但是有时会观察到应用程序崩溃而没有留下任何错误/异常迹象。

让我详细说明一下方案:

  1. The Application creates few threads, all the threads have try-catch block added at the beginning of their call stacks. And hence log fetal exceptions before crashing.
  2. The main thread have 'AppDomain.CurrentDomain.UnhandledException' to log any fetal exceptions on its call stack.
  3. The application does load some third party managed dlls and performs some PInvokes on Wnce dlls.


但是我相信,即使某些第三方DLL崩溃了(或者说它创建了一个新的崩溃的线程),我也至少应该在日志中看到一些 ThreadAbortExceptions,由应用程序的线程记录下来,然后退出。

Nlog的关键配置参数为:

a. FileTarget.AutoFlush = true

b. FileTarget.KeepFileOpen= false

c. FileTarget is not wrapped in any async wrapper or in any buffered wrapper.



如果我有任何遗漏,请告诉我。

最佳答案

崩溃的可能原因包括OutOfMemory异常或StackOverflowException。从documentation for the latter:

Version Considerations

In prior versions of the .NET Framework, your application could catch a StackOverflowException object (for example, to recover from unbounded recursion). However, that practice is currently discouraged because significant additional code is required to reliably catch a stack overflow exception and continue program execution.

Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default. Consequently, users are advised to write their code to detect and prevent a stack overflow. For example, if your application depends on recursion, use a counter or a state condition to terminate the recursive loop. Note that an application that hosts the common language runtime (CLR) can specify that the CLR unload the application domain where the stack overflow exception occurs and let the corresponding process continue. For more information, see ICLRPolicyManager Interface and Hosting Overview.

关于crash - 应用程序崩溃时,没有致命异常的迹象NLog版本2 |紧凑框架3.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8731208/

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