Skip to content

Repository files navigation

ErrorSight SDK for .NET Framework 4.0

ErrorSight is an observability SDK that captures logs, exceptions, and active window screenshots from .NET Framework 4.0 applications. It is designed for WinForms and WPF desktop software that needs real-time error tracking without upgrading the runtime.

The SDK sends data to the ErrorSight API over HTTPS using OAuth2 authentication. You can either self-host the backend or use the hosted service.


Features

  • Log levels: Debug, Info, Warn, Error, Fatal
  • Automatic screenshot capture of the active window on errors
  • Global exception handling for AppDomain and WinForms
  • OAuth2 client credentials flow
  • Batch sending with background queue
  • Proxy support for corporate environments
  • App.config integration
  • Configurable sampling and filtering via BeforeSend events

Requirements

  • .NET Framework 4.0 or higher
  • Newtonsoft.Json 13.0.4
  • An ErrorSight API endpoint (self-hosted or hosted)

Installation

Install via NuGet Package Manager:

Install-Package ErrorSight.SDK.Net40

Or via the NuGet CLI:

nuget install ErrorSight.SDK.Net40

Configuration

Option A: App.config

Add the following keys to your App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="ErrorSight:ApiBaseUrl" value="https://api.errorsight.io"/>
    <add key="ErrorSight:OAuthTokenUrl" value="https://auth.errorsight.io/oauth/token"/>
    <add key="ErrorSight:ClientId" value="your-client-id"/>
    <add key="ErrorSight:ClientSecret" value="your-client-secret"/>
    <add key="ErrorSight:ProjectKey" value="my-app-v1"/>
    <add key="ErrorSight:ScreenshotFormat" value="Base64"/>
    <add key="ErrorSight:CaptureOnlyOnError" value="true"/>
    <add key="ErrorSight:BatchSize" value="10"/>
    <add key="ErrorSight:FlushIntervalMs" value="5000"/>
    <add key="ErrorSight:RequestTimeoutMs" value="30000"/>
  </appSettings>
</configuration>

Then initialize:

ErrorSight.SDK.Core.ErrorSightClient.InitializeFromAppSettings();

Option B: Code

using ErrorSight.SDK.Core;
using ErrorSight.SDK.Models;

var config = new ErrorSightConfig
{
    ApiBaseUrl = "https://api.errorsight.io",
    OAuthTokenUrl = "https://auth.errorsight.io/oauth/token",
    ClientId = "your-client-id",
    ClientSecret = "your-client-secret",
    ProjectKey = "my-app-v1",
    ScreenshotFormat = ScreenshotFormat.Base64,
    CaptureOnlyOnError = true,
    BatchSize = 10,
    FlushIntervalMs = 5000
};

ErrorSightClient.Initialize(config);

Usage

Basic Logging

ErrorSightClient.LogInfo("Application started");

ErrorSightClient.LogDebug("User clicked save", new Dictionary<string, object>
{
    { "Form", "MainForm" },
    { "UserId", 42 }
});

Exception Handling

try
{
    // risky operation
}
catch (Exception ex)
{
    ErrorSightClient.LogError(ex, new Dictionary<string, object>
    {
        { "Operation", "DatabaseSave" }
    });
}

Global Exception Handlers

Attach once during application startup:

ErrorSightExceptionHandler.AttachAppDomain();
ErrorSightExceptionHandler.AttachWinForms();

This captures unhandled exceptions and thread exceptions automatically.

BeforeSend Callback

Filter or mutate logs before they are sent:

ErrorSightClient.BeforeSend += (sender, e) =>
{
    if (e.Entry.Message.Contains("password"))
        e.Cancel = true;
};

Shutdown

Call on application exit to flush the queue:

ErrorSightClient.Shutdown();

Backend Options

The SDK communicates with a Go-based backend. Two deployment models are available.

1. Self-Hosted (Open Source)

Host the backend on your own infrastructure using Docker.

Docker Compose

services:
  errorsight-api:
    image: ghcr.io/errorsight/errorsight-api:latest
    ports:
      - "8080:8080"
    environment:
      - ES_DATABASE_DSN=postgres://errorsight:secret@db:5432/errorsight?sslmode=disable
      - ES_OAUTH_ISSUER=https://auth.errorsight.io
      - ES_STORAGE_PATH=/data/screenshots
    volumes:
      - ./data:/data
    depends_on:
      - db

  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_USER: errorsight
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: errorsight
    volumes:
      - pgdata:/var/lib/postgresql/data

volumes:
  pgdata:

Clone the backend repository and build the image:

git clone https://github.com/errorsight/errorsight-api.git
cd errorsight-api
docker build -t errorsight-api .

2. Hosted Service

The managed multitenant version is available at https://errorsight.io. Sign up to receive your OAuth2 credentials and project key.


Support

For bug reports and feature requests, open an issue on GitHub.

If you find ErrorSight useful, consider supporting development via Ko-fi:

https://ko-fi.com/aztekode

For enterprise inquiries, contact: contact@errorsight.io


License

MIT License

Copyright (c) 2026 ErrorSight by Aztekode. Developed by Eddy Ortega (atrox39).

About

ErrorSight observability SDK for .NET Framework 4.0. Capture logs, exceptions, and active window screenshots from WinForms and WPF applications. Includes OAuth2 authentication, batch sending, App.config support, and proxy configuration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages