winforms-development

Guides creation and modernization of .NET WinForms applications with Designer-compatible code organization.

1|1|Updated Jun 12, 2022
One-click install
npx skills add https://github.com/KlausLoeffelmann/WinFormsDevTools --skill winforms-development-klausloeffelmann
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: winforms-development
Source: https://github.com/KlausLoeffelmann/WinFormsDevTools/tree/main/.github/skills/winforms-development
Command: npx skills add https://github.com/KlausLoeffelmann/WinFormsDevTools --skill winforms-development-klausloeffelmann

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? WinForms development spans two conflicting code contexts—Designer-generated serialization files and modern application logic—and mixing their rules breaks Designer compatibility or causes runtime crashes. This Skill provides the conventions, project setup, and patterns needed to build and modernize .NET WinForms applications correctly. ## Core Features & Use Cases - Project Setup: Configures .csproj files, Program.cs startup, DarkMode, and DPI awareness for .NET 8/9/10 WinForms apps in C# and Visual Basic. - Two-Context Code Rules: Enforces strict separation between Designer files (C# 2.0 serialization format) and regular code files (modern C# 11-14 features like nullable types, pattern matching, and target-typed new). - Async & Exception Safety: Covers InvokeAsync overloads, fire-and-forget traps, and mandatory try/catch in async event handlers to prevent application crashes. - Use Case: When migrating a legacy .NET Framework WinForms app to .NET 9, follow the migration checklist to enable nullable reference types, add DarkMode support, and update async patterns while keeping Designer files intact. ## Quick Start Ask the AI to create a new .NET 10 WinForms project with DarkMode support and proper Designer-compatible file organization.

Frequently Asked Questions about winforms-development

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

FAQPage Schema
How do I set up a new .NET WinForms project?▼

Create a .csproj with Microsoft.NET.Sdk, set OutputType to WinExe, TargetFramework to net10.0-windows, and UseWindowsForms to true. In Program.cs, call ApplicationConfiguration.Initialize(), then set DarkMode and HighDpiMode before Application.Run.

How to enable DarkMode in a WinForms application?▼

DarkMode requires .NET 9 or later. Call Application.SetColorMode(SystemColorMode.System) at startup in C#, or set e.ColorMode in the VB ApplicationEvents ApplyApplicationDefaults handler. Use SystemColors so colors adapt automatically.

Can I use modern C# features in WinForms Designer files?▼

No, Designer files are a serialization format parsed by the Designer, not compiled code. On .NET 10 and below, InitializeComponent must use C# 2.0-level syntax only; lambdas and modern operators break Designer compatibility.

Why does my WinForms app crash in async event handlers?▼

Unhandled exceptions in async void event handlers crash the application because there is no caller to catch them. Always wrap awaited calls in try/catch inside the handler and display or log the exception.

Should I use app.config or manifest files for DPI settings?▼

No, avoid app.config and manifest files for DPI configuration. Use code-based configuration by calling Application.SetHighDpiMode(HighDpiMode.SystemAware) at application startup instead.