Skip to content
Artyom M. edited this page Nov 2, 2026 · 2 revisions

Welcome to the Scarlet.Extensions.Hosting.DirectN wiki!

An unofficial implementation of Microsoft.Extensions.Hosting for DirectN (Win32 / Direct2D) desktop applications. This library brings the power of the .NET Generic Host to DirectN, enabling dependency injection, configuration, logging, and hosted services in your desktop applications, Native AOT compatible end to end.

This wiki describes version 1. Coming from WPF? See Migrating from Extensions.Hosting.Wpf.

Key Features

  • Generic Host integration for DirectN applications, with Host.CreateApplicationBuilder (IHostApplicationBuilder) or Host.CreateDefaultBuilder (IHostBuilder)
  • Native AOT: every package is IsAotCompatible and verifies that its references are too
  • Components created, initialized and disposed on the UI thread, with constructor injection
  • Predictable lifecycle: the UI thread starts after every hosted service has started and stops before them, and startup failures surface from host.Run()
  • A reliable UI-thread SynchronizationContext: works before the UI thread starts and inside modal loops, flows the caller's ExecutionContext, and never hangs or throws on shutdown
  • System tray icon support with WinForms NotifyIcon behavior (optional extension)
  • Thread switching between UI and background threads with JoinableTaskFactory and AsyncLazy<T> (optional extension)

Table of Contents

  1. Introduction
  2. NuGet Packages
  3. Getting Started
  4. Components
  5. Application Options
  6. DirectN Lifetime
  7. Threading Extension
  8. TrayIcon Extension
  9. Message Queue
  10. Architecture & How It Works
  11. API Reference
  12. Samples Overview
  13. FAQ & Troubleshooting
  14. Migrating from Extensions.Hosting.Wpf

Quick Links

Clone this wiki locally