简体   繁体   English

崩溃 C# 应用程序并生成转储

[英]Crash C# Application and Generate Dumps

I'm trying to generate dumps for my C# application, I used the FailFast method to "Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and optional exception information in error reporting to Microsoft."我正在尝试为我的 C# 应用程序生成转储,我使用 FailFast 方法“在向 Windows 应用程序事件日志写入消息后立即终止进程,然后将消息和可选的异常信息包含在向 Microsoft 的错误报告中。”

static void Main(string[] args)
        {
        string causeOfFailure = "This is a test crash.";
            try
            {
                Environment.FailFast(causeOfFailure);
            }
            finally
            {
                Console.WriteLine("This finally block will not be executed.");
            }}

I managed to get the error on event viewer, however Dumps are not generated我设法在事件查看器上得到错误,但是没有生成转储在此处输入图像描述

This is my settings for the dumps in the registry:这是我在注册表中的转储设置:

在此处输入图像描述

I kept default values, so the Dump folder should be %LOCALAPPDATA%\CrashDumps However, no dumps are generated我保留了默认值,所以转储文件夹应该是 %LOCALAPPDATA%\CrashDumps 但是,没有生成任何转储

I see in your event viewer screenshot that your app uses .NET Framework 2.0.我在您的事件查看器屏幕截图中看到您的应用程序使用 .NET Framework 2.0。 It seems the crash dump only works in .NET Framework 4.0 and above.故障转储似乎仅适用于 .NET Framework 4.0 及更高版本。 Try changing the targeted .NET Framework.尝试更改目标 .NET 框架。

  1. In your Solution Explorer, right-click your project and select Properties在您的解决方案资源管理器中,右键单击您的项目和 select Properties
  2. In Properties, go to the Application option on the side menu在属性中,go 到侧面菜单上的应用程序选项
  3. Locate the Target framework dropdown and select the framework version 4.0 or above.找到目标框架下拉列表和 select 框架版本 4.0 或更高版本。

I tested this on my machine.我在我的机器上测试了这个。 When targeting .NET 2.0 there is no crash dump.当以 .NET 2.0 为目标时,没有故障转储。 When targeting .NET 4.0 I get a crash dump.当以 .NET 4.0 为目标时,我得到了一个故障转储。

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

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