Skip to content

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

@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

Labels

area-VSDesignerWindows Forms out-of-proc designer related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy