Skip to content

WinForms VB.NET Designer requires WithEvents in .NET 11 whereas the same project works in .NET 10 #15366

Open

Description

@SaranRajChandrasekaran

Environment

Visual Studio Professional 2026 - Version: 18.11.3,
Visual Studio Professional 2026 Insiders - Version: 12328.396,

.NET version

.NET11

Did this work in a previous version of Visual Studio and/or previous .NET release?

No response

Issue description

We observed a difference in WinForms VB.NET Designer behavior between .NET 10 and .NET 11.

In .NET 10, a designer-generated control declared as:

Private Label1 As Label

works correctly, and the project builds, runs, and loads in the WinForms Designer without issues.

However, after migrating the same project to .NET 11, the WinForms Designer reports the following error:

1>D:\Winforms\WinFormsApp2\Form1.Designer.vb(49,13): error WFO3011: Designer component member 'Label1' must support the VB event model; add WithEvents to its declaration and use Handles for its named event handlers in the user partial (https://aka.ms/winforms-warnings/wfo3011)

The issue is resolved when the control declaration is changed to:

Friend WithEvents Label1 As Label

We would like to understand whether this is an intentional change in the .NET 11 WinForms Designer, a stricter designer validation rule, or a regression. We would also appreciate any documentation that explains why controls that previously worked without WithEvents in .NET 10 now require WithEvents in .NET 11.

Steps to reproduce

  1. Create a WinForms VB.NET project targeting .NET 10.

  2. Add a Label control to a form.

  3. Modify the designer declaration from:

    Friend WithEvents Label1 As Label

    to:

    Private Label1 As Label

  4. Verify that the project builds and runs successfully in .NET 10.

  5. Upgrade the project to target .NET 11.

  6. Open the form in the WinForms Designer.

  7. Observe that the Designer reports the following error:

    "Designer component member 'Label1' must support the VB event model; add WithEvents to its declaration and use Handles for its named events."

  8. Change the declaration back to:

    Friend WithEvents Label1 As Label

  9. Reopen the Designer and verify that the error is resolved.

Diagnostics


Activity

  1. paul1956 commented on Nov 5, 2026

    @paul1956
    Contributor

    @SaranRajChandrasekaran I believe there are stricter designer validation rules in the newer WinForms designer that are documented in "what's new". In my case the required changes were backward compatible to previous versions of .Net. "wfo3011" is just one of several.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedThe team needs to look at this issue in the next triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions