dotnet-winforms

Applies WinForms conventions for MVP architecture, DI, async, disposal, and high-DPI maintenance.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/envoydev/claude-stack --skill dotnet-winforms-envoydev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-winforms
Source: https://github.com/envoydev/claude-stack/tree/main/stack/skills/dotnet-winforms
Command: npx skills add https://github.com/envoydev/claude-stack --skill dotnet-winforms-envoydev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? WinForms codebases accumulate logic in code-behind, leak GDI handles, and deadlock on the UI thread, making maintenance and modernization of line-of-business desktop apps error-prone. This Skill enforces the conventions that keep Forms testable, leak-free, and ready to move from .NET Framework 4.8 to modern .NET. ## Core Features & Use Cases - Architecture separation: Enforces MVP passive view (or the .NET 8 MVVM binding engine for new work) so presenters unit-test against a mocked IView with no UI thread. - Runtime-specific mechanics: References cover .NET Framework 4.8 as the frozen maintenance surface and .NET 8/9/10 as the strategic target, including InvokeAsync, async forms, dark mode, and PerMonitorV2 high-DPI setup. - Leak and disposal discipline: Provides per-case rules for event-handler and GDI/USER handle leaks, plus a flat-handle-count acceptance bar before shipping. - Use Case: When modernizing a 4.8 WinForms app to .NET 10, load this Skill to convert forms to DI-resolvable MVP views, replace BackgroundWorker with async/await and IProgress<T>, and validate the migration with a handle-count stress test. ## Quick Start Load the dotnet-winforms skill before editing any Form, UserControl, code-behind, presenter, or .Designer.cs file in this WinForms project.

Frequently Asked Questions about dotnet-winforms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep business logic out of WinForms code-behind?▼

Use the MVP passive view pattern: the Form implements a narrow IView interface with properties for values and events for intent, while the presenter owns all decisions and unit-tests against a mocked view. On .NET 8 and later, the MVVM binding engine with DataContext and ICommand is an alternative.

How do I update the WinForms UI from a background thread?▼

Marshal to the UI thread with Control.Invoke or BeginInvoke, or Control.InvokeAsync from .NET 9. Report progress with IProgress<T>, which captures the UI SynchronizationContext. Never block with .Result or .Wait(), which deadlocks the WindowsFormsSynchronizationContext.

Does WinForms support dependency injection on .NET Framework 4.8?▼

Yes, Microsoft.Extensions.DependencyInjection runs on 4.8. Build a ServiceCollection, register forms and services, call BuildServiceProvider once at startup, and resolve the main form for Application.Run. Modern .NET uses Host.CreateApplicationBuilder instead.

Why does my WinForms app leak GDI handles?▼

Leaks come from undisposed System.Drawing objects like Pen, Brush, Font, and Graphics, or event handlers where a short-lived object subscribes to a long-lived publisher. Wrap created drawing objects in using, detach handlers in Dispose, and verify with flat GDI and USER handle counts in Task Manager.

FlaUI vs WinAppDriver for WinForms UI testing?▼

FlaUI over UI Automation is the choice for new WinForms UI tests, using the UIA2 backend. WinAppDriver is effectively dead, with its last release in November 2020 and unmaintained issues. Keep UI tests at smoke and critical-path scope only.

When should I not use this WinForms skill?▼

Do not load it for WPF, WinUI 3, MAUI, Avalonia, or Uno, which have their own conventions. It also excludes the general C# async and nullable baseline, test framework mechanics, and the broader .NET upgrade playbook, which belong to sibling skills.