Skip to content

WinForms Designer Error: Could Not Determine a Valid Designer Type for Custom ToolStrip in .NET Core #13507

Open
@NagarajManimaran

Description

@NagarajManimaran

Environment

Visual Studio professional 2022 - version 17.13.0

.NET version

.NetCore 6,7,8

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

No, it doesn't work on previous NetCore versions.

Issue description

We encountered the following error in the Output window when adding a CustomToolStrip component to a form in design view in .NET Core:

fail: Could not determine a valid designer type for 'customcontrol.CustomToolStripDesigner, customcontrol'.

For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting

In our implementation, the CustomToolStripDesigner uses reflection to load and invoke Microsoft’s internal ToolStripDesigner within its Initialize method. We assumed that this reflection approach might not be functioning correctly in .NET Core.

Image

Upon further analysis, we found the following:

The Microsoft ToolStrip control is part of the System.Windows.Forms assembly, which is available in both .NET Framework and .NET Core/.NET, so it functions properly in both environments.

However, the ToolStripDesigner class resides in the System.Design assembly, which is only available in .NET Framework and not supported in .NET Core/.NET.
As a result, referencing or reflecting this designer type in .NET Core fails, leading to the designer not being initialized and the error shown in the Output window.

Note: While ToolStripDesigner is available in the System.Design assembly in .NET Framework, it is not available in .NET Core—even though the ToolStrip itself is supported in both environments.

We also compared the reflection behavior between .NET Framework and .NET Core and observed that: We have attached a screenshot below showing the differences in reflection behavior for clarity.

Framework:

Image

Core:

Image

I attached the netcore sample project also

customcontrol.zip

How to achieve this in .NetCore?

Steps to reproduce

Drag and drop the CustomToolStrip onto a WinForms form in a .NET Core project.

Then, check the Output window in Visual Studio by selecting 'Show output from: Windows Forms Designer' from the dropdown.

Diagnostics


Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VSDesignerWindows Forms out-of-proc designer related issuesuntriagedThe 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