Nefarius.Utilities.ExceptionEnricher 1.14.0-pre022

Prefix Reserved
This is a prerelease version of Nefarius.Utilities.ExceptionEnricher.
dotnet add package Nefarius.Utilities.ExceptionEnricher --version 1.14.0-pre022
                    
NuGet\Install-Package Nefarius.Utilities.ExceptionEnricher -Version 1.14.0-pre022
                    
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="Nefarius.Utilities.ExceptionEnricher" Version="1.14.0-pre022" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nefarius.Utilities.ExceptionEnricher" Version="1.14.0-pre022" />
                    
Directory.Packages.props
<PackageReference Include="Nefarius.Utilities.ExceptionEnricher" />
                    
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 Nefarius.Utilities.ExceptionEnricher --version 1.14.0-pre022
                    
#r "nuget: Nefarius.Utilities.ExceptionEnricher, 1.14.0-pre022"
                    
#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 Nefarius.Utilities.ExceptionEnricher@1.14.0-pre022
                    
#: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=Nefarius.Utilities.ExceptionEnricher&version=1.14.0-pre022&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Nefarius.Utilities.ExceptionEnricher&version=1.14.0-pre022&prerelease
                    
Install as a Cake Tool

Nefarius.Utilities.ExceptionEnricher

Requirements Nuget Nuget

Motivation

Having stack traces on exceptions including line numbers and the source file name of the offending code is a luxury we're accustomed to in local debug builds, not so much in the field though.

Getting readable exceptions requires debug symbols being present at the time the exception/stack trace is thrown/generated, so you'd typically need to include your .pdb files with your published app, at the cost of increased size of the deliverables.

This library tries to tackle this conundrum by on-demand downloading the required symbols from a symbol server you can host yourself whenever an "enriched" exception is thrown. You can then send this enriched exception to your logging or tracing subsystem and enjoy the comfort of readable stack traces! Symbols are held in memory until application termination to reduce the required http calls to a minimum.

Limitations

<No sequence point found, async method?>

Currently, file names and line numbers cannot be looked up correctly through the use of Mono.Cecil alone, so you will get this "error" instead.

Example

Here we have a classic ToString() on an exception object in a production release with no symbols:

System.InvalidOperationException: Test exception
   at Program.<<Main>$>g__Baz|0_2()
   at Program.<<Main>$>g__Bar|0_1(List`1 someArgs)
   at Program.<<Main>$>g__Foo|0_0(Int32 firstArg, Int32 secondArg)
   at Program.<Main>$(String[] args)

If we enrich the same exception by on-demand downloading remote symbols, we get something way more helpful:

System.InvalidOperationException: Test exception
   at Program.<<Main>$>g__Baz|0_2() in D:\Development\GitHub\WinDbgSymbolsCachingProxy\testapp\Program.cs (line 47)
   at Program.<<Main>$>g__Bar|0_1(List<Int32> someArgs) in D:\Development\GitHub\WinDbgSymbolsCachingProxy\testapp\Program.cs (line 42)
   at Program.<<Main>$>g__Foo|0_0(Int32 firstArg, Int32 secondArg) in D:\Development\GitHub\WinDbgSymbolsCachingProxy\testapp\Program.cs (line 36)
   at Program.<Main>$(String[] args) in D:\Development\GitHub\WinDbgSymbolsCachingProxy\testapp\Program.cs (line 10)

Setup

  • Wherever you catch and process your apps' fatal exceptions use ex.ToRemotelyEnrichedException(client) instead of ex directly
  • Add or adjust the debug type for your release build in your .csproj like so:
        <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
          <DebugType>full</DebugType>
        </PropertyGroup>
    
  • Use the harvesting agent (or whatever method you prefer) to collect the resulting .pdb files and upload them to your symbol server instance
  • Package your app for your users without the .pdb files included
  • Now whenever an exception is thrown (and the user has an active Internet connection, and you configure everything right), you will get proper useful stack traces when you send the exception details to your logging framework 💪

Documentation

Link to API docs.

Sources & 3rd party credits

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.14.0-pre022 575 1/27/2025
1.14.0-pre021 58 1/27/2025
1.14.0-pre020 95 1/27/2025
1.14.0-pre019 75 1/26/2025
1.14.0-pre018 67 1/26/2025
1.14.0-pre017 72 1/26/2025
1.14.0-pre016 63 1/26/2025
1.14.0-pre015 62 1/25/2025
1.14.0-pre014 88 1/25/2025
1.14.0-pre013 64 1/25/2025
1.14.0-pre012 71 1/25/2025
1.14.0-pre011 65 1/25/2025
1.14.0-pre010 66 1/25/2025
1.14.0-pre009 58 1/25/2025
1.14.0-pre008 69 1/25/2025
1.14.0-pre007 67 1/25/2025
1.14.0-pre006 62 1/25/2025
1.14.0-pre005 60 1/25/2025
1.14.0-pre004 57 1/24/2025
1.14.0-pre003 58 1/24/2025