winforms icon indicating copy to clipboard operation
winforms copied to clipboard

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

Open NagarajManimaran opened this issue 7 months ago • 4 comments

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


NagarajManimaran avatar May 22 '25 06:05 NagarajManimaran

Any further updates reg these query?

NagarajManimaran avatar May 26 '25 10:05 NagarajManimaran

Why doesn't CustomToolStripDesigner directly inherit ControlDesigner?

LeafShi1 avatar May 27 '25 09:05 LeafShi1

Thank you for your response.

To clarify, our CustomToolStripDesigner does directly inherit from ControlDesigner. However, the default Microsoft ToolStripDesigner—which also inherits from ControlDesigner

Image

—includes rich design-time features such as support for smart tags, item collection editing, add toolstrip items, overflow handling, and more. Our goal was to leverage those existing capabilities for our custom control, which is why we attempted to load and invoke ToolStripDesigner via reflection.

This approach works in .NET Framework, where the System.Design assembly (which contains ToolStripDesigner) is available. However, in .NET Core/.NET 5+:

  • The System.Design assembly is not available.
  • While we can still use reflection to retrieve types and members from loaded assemblies, ToolStripDesigner is simply not part of the supported assemblies, so the designer fails to initialize, even though we can inspect the type metadata via reflection.

Because of this, our current approach (reflection-based delegation to ToolStripDesigner) is not available in .NET Core.

Our Question: Given that ToolStripDesigner and its features are not available in .NET Core, what is the recommended way to replicate or approximate the same designer functionality (smart tags, item editing support, etc.) for a custom ToolStrip-like control in .NET Core?

Are there any updated or supported design-time extensibility APIs for ToolStrip-related functionality in .NET Core/WinForms that we could use to replace the functionality previously offered by ToolStripDesigner?

We’d appreciate any guidance or samples on how to achieve similar behavior in the modern .NET Designer environment.

Thank you again for your assistance.

NagarajManimaran avatar May 27 '25 11:05 NagarajManimaran

Please refer to this article https://devblogs.microsoft.com/dotnet/custom-controls-for-winforms-out-of-process-designer/

LeafShi1 avatar May 28 '25 09:05 LeafShi1

Thanks for the update.

I reviewed the article you shared regarding the client-server approach in the out-of-process WinForms designer. I attempted to use reflection in the designer as described, but the issue still persists in .NET Core. Reflection works correctly in .NET Framework, but not in .NET Core.

Could you please confirm whether reflection is fully supported in the .NET Core designer environment? If so, it would be helpful if you could share a working sample, reference implementation, or any relevant documentation that demonstrates this.

NagarajManimaran avatar Jul 11 '25 04:07 NagarajManimaran

@LeafShi1 any updates on these query? https://github.com/dotnet/winforms/issues/13507#issuecomment-3060521268

NagarajManimaran avatar Oct 01 '25 10:10 NagarajManimaran