Logo Microsoft
Docs & ÉcritureSûr100100/100

Managing Winforms Designer Code (Microsoft)

Governs WinForms Designer-generated code structure and InitializeComponent patterns. Use when writing or reviewing .Designer.cs files, fixing "Designer file cannot be loaded" errors, resolving Designer round-trip issues, validating control instantiation in InitializeComponent, implementing proper Dispose(bool disposing) pattern with components.Dispose(), working with IContainer and components field, troubleshooting Designer serialization failures, organizing Designer code vs application logic separation, or understanding what code belongs in InitializeComponent vs elsewhere. Also triggers for "InitializeComponent", ".Designer.cs file", "Designer cannot load", "components.Dispose", "IContainer field", "Designer compatibility", "Designer round-trip", and "Form Designer errors".

ou envoie-le directement à ton agent.

Installer dans ton projet

$ curl -fsSL https://arboristhree.xyz/cli/install-skill.mjs -o /tmp/arboris-install-skill.mjs && node /tmp/arboris-install-skill.mjs managing-winforms-designer-code__microsoft-upgrade-agent-plugins__plugins-upgrade-agent-extenders-upgrade-dotnet-upgrade-skills-lazy-desktop-winfo-3075282c80b0
Logo Microsoft
Microsoft
microsoft/upgrade-agent-plugins
Contenu à copier
---

name: managing-winforms-designer-code
description: >
  Governs WinForms Designer-generated code structure and InitializeComponent patterns. Use when
  writing or reviewing .Designer.cs files, fixing "Designer file cannot be loaded" errors,
  resolving Designer round-trip issues, validating control instantiation in InitializeComponent,
  implementing proper Dispose(bool disposing) pattern with components.Dispose(), working with
  IContainer and components field, troubleshooting Designer serialization failures, organizing
  Designer code vs application logic separation, or understanding what code belongs in
  InitializeComponent vs elsewhere. Also triggers for "InitializeComponent", ".Designer.cs
  file", "Designer cannot load", "components.Dispose", "IContainer field", "Designer
  compatibility", "Designer round-trip", and "Form Designer errors".
metadata:
  origin: Microsoft
  discovery: lazy
  traits: (.NET|CSharp|VisualBasic|DotNetCore) & WindowsForms
---


# WinForms Designer Code Rules

The WinForms Designer generates serialization code, not regular C# code. Understanding and following these rules is CRITICAL for Designer compatibility. **All WinForms Forms and UserControls should be Designer-compatible** — these rules are not optional guidance but mandatory constraints for any code that the Designer must be able to round-trip (read, modify, and re-serialize).

## When to Use This Skill

Use this skill when:

- Generating the code which makes up a Form or a UserControl in WinForms.
- Writing or modifying `.Designer.cs` or `.Designer.vb` files
- Creating user controls that need Designer support
- Reviewing Designer-generated code
- Reviewing whether WinForms Forms/UserControls are "designed according to standard", "not designed properly", or similar; pair this with `managing-winforms-high-dpi-layout` so both Designer serialization and human/layout/DPI quality are checked.
- Debugging Designer-related issues
- Migrating forms between .NET Framework and .NET
- Migrating VB6 Code to either Visual Basic (.NET) or C# WinForms Projects.

**IMPORTANT:** Other skills (layout, rendering, data binding, MVVM) describe *what* to build. This skill defines *how* the Designer code-behind file must be structured. When those skills show control configuration, the actual property assignments belong in `InitializeComponent` following the rules below.


## Related Skills
- [building-winforms-applications](../building-winforms-applications/SKILL.md)
- [managing-winforms-data-binding](../managing-winforms-data-binding/SKILL.md)
- [managing-winforms-mvvm](../managing-winforms-mvvm/SKILL.md)
- [managing-winforms-high-dpi-layout](../managing-winforms-high-dpi-layout/SKILL.md)
- [creating-winforms-custom-controls](../creating-winforms-custom-controls/SKILL.md)


## Detailed Guidance
Read [Detailed guide](ref/detailed-guide.md) for comprehensive patterns, examples, and troubleshooting.

## Workflow
1. Confirm the scenario matches the triggers in this skill.
2. Apply the baseline pattern from this file.
3. Read [Detailed guide](ref/detailed-guide.md) for advanced or edge-case handling.
4. Validate changes with an actual build and runtime check.
Colle ce Markdown dans ton agent ou utilise les boutons ci-dessus pour l’écrire dans ton projet.

Ce que fait Managing Winforms Designer Code (Microsoft)

Generating the code which makes up a Form or a UserControl in WinForms.
Writing or modifying `.Designer.cs` or `.Designer.vb` files
Creating user controls that need Designer support
Reviewing Designer-generated code

Comment utiliser Managing Winforms Designer Code (Microsoft)

1
Copie le prompt
Un clic copie le prompt packagé (ou l'envoie à ton agent).
2
L'agent installe le skill
Il ajoute le SKILL.md et ses ressources à ton projet.
3
Activation automatique
Le skill s'active dès que le contexte correspond.

Déclencheurs pour Managing Winforms Designer Code (Microsoft)

Dis simplement à ton agent quelque chose comme :

Applique le skill managing-winforms-designer-code__microsoft-upgrade-agent-plugins__plugins-upgrade-agent-extenders-upgrade-dotnet-upgrade-skills-lazy-desktop-winfo-3075282c80b0 à cette tâche
Utilise managing-winforms-designer-code__microsoft-upgrade-agent-plugins__plugins-upgrade-agent-extenders-upgrade-dotnet-upgrade-skills-lazy-desktop-winfo-3075282c80b0 pour améliorer cette implémentation
Passe en revue ce sujet avec managing-winforms-designer-code__microsoft-upgrade-agent-plugins__plugins-upgrade-agent-extenders-upgrade-dotnet-upgrade-skills-lazy-desktop-winfo-3075282c80b0

Skills liés à Managing Winforms Designer Code (Microsoft)