VassasCo.Utility.CrashDumpHelper 1.2.0

dotnet add package VassasCo.Utility.CrashDumpHelper --version 1.2.0
                    
NuGet\Install-Package VassasCo.Utility.CrashDumpHelper -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VassasCo.Utility.CrashDumpHelper" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VassasCo.Utility.CrashDumpHelper" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="VassasCo.Utility.CrashDumpHelper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VassasCo.Utility.CrashDumpHelper --version 1.2.0
                    
#r "nuget: VassasCo.Utility.CrashDumpHelper, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VassasCo.Utility.CrashDumpHelper@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VassasCo.Utility.CrashDumpHelper&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=VassasCo.Utility.CrashDumpHelper&version=1.2.0
                    
Install as a Cake Tool

CrashDumpHelper

崩溃捕获工具。记录崩溃前的 FirstChance 异常链、UnobservedTaskException 异常 + 生成 Windows MiniDump 文件。

文件说明

文件 内容
CrashDumpHelper.cs 全部功能:异常监听、崩溃日志、MiniDump 生成

快速开始

// 程序启动时初始化(越早越好,默认同时开启 Task 异常监听)
CrashDumpHelper.Initialize();

// 如需关闭 Task 异常监听:
CrashDumpHelper.Initialize(alsoCaptureTaskExceptions: false);

// 在 UnhandledException 中记录
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
    var ex = (Exception)e.ExceptionObject;
    CrashDumpHelper.FlushAndWriteCrashLog(ex, "AppDomain.UnhandledException");
};

API

// 初始化(默认 alsoCaptureTaskExceptions = true)
CrashDumpHelper.Initialize();

// 记录崩溃日志
CrashDumpHelper.WriteCrashLog(exception, "来源描述");

// 先 flush 日志系统再记录崩溃
CrashDumpHelper.FlushAndWriteCrashLog(exception, "来源描述");

UnobservedTaskException 捕获(v1.2.0 新增)

Task.Run 内部抛出异常但无人 await 时,该异常会在 GC 回收 Task 时被捕获并记录到 FirstChance 日志中。此功能默认开启。

// 开启
CrashDumpHelper.Initialize();  // 默认 true

// 关闭
CrashDumpHelper.Initialize(alsoCaptureTaskExceptions: false);

注意:此事件在 GC 回收 Task 时触发(非立即),记录了异常类型、消息和堆栈首行。调用 e.SetObserved() 标记已观察,防止启用了 ThrowUnobservedTaskExceptions 的进程崩溃。

生成的文件

崩溃后会在 {程序目录}/CrashLogs/ 下生成:

文件 说明
Crash_20250617.log 崩溃日志(含 FirstChance 记录、未观察 Task 异常、异常详情、堆栈)
CrashDump_20250617_143025_12345.dmp Windows MiniDump 文件

注意事项

  • MiniDump 生成依赖 Windows dbghelp.dll,非 Windows 平台只生成日志
  • FlushAndWriteCrashLog 通过反射调用 LogHelper,如果不存在则静默跳过
  • 最多记录 50 条 FirstChance 异常(循环覆盖)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on VassasCo.Utility.CrashDumpHelper:

Package Downloads
VassasCo.Utility

C# 桌面开发工具库 (WinForm / WPF / Avalonia): - ConfigHelper:零代码实体类⇋JSON/XML配置双向映射(带注释、热重载、原子保存、列表展开) - LogHelper:异步高性能日志系统(建造者模式、异步队列、自动清理、14种日志类型) - CrashDumpHelper:崩溃捕获+FirstChance异常追踪+MiniDump生成 - SnowflakeIdHelper:分布式雪花ID生成器(单调时钟杜绝回拨、集群WorkerId分配、ID反解) - ScheduleHelper:全能定时任务调度器(CRON/固定速率/固定延迟、重试退避、超时取消、日历过滤、线程池、优雅关闭) - RetryHelper:智能重试器(指数退避+抖动+断路器三态+降级+超时,同步/异步) - EventBus:进程内事件总线(类型发布/订阅、特性自动注册、优先级、条件过滤、粘性事件、多通道),支持 .NET Standard 2.0 / .NET 6 / .NET 8 / .NET 9 / .NET 10 - ExcelMapper:原生对象→Excel映射(嵌套类子表头合并、数组独立Sheet、Dictionary自适应、全可配置样式)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 259 6/28/2026
1.1.0 219 6/18/2026