dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.37k stars 966 forks source link

How to fix the issue: "The following controls were successfully added to the toolbox but are not enabled in the active designer" #8077

Open zydjohnHotmail opened 1 year ago

zydjohnHotmail commented 1 year ago

Environment

Visual Studio 2022 (Version 17.3.6). OS: Windows 10 PRO (Version 21H2)

.NET version

.NET 6.0

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

Yes. I can download and run its source in Visual Studio 2022 (the latest version). The .csproj showed its target:

net5.0-windows;net40
<OutputType>Library</OutputType>

Issue description

My IDE: Visual Studio 2022 (Version 17.3.6). I want to port one custom control from this repo: https://github.com/dwmkerr/consolecontrol According to suggestions of the author, I simply import the custom control dll file: consolecontrol.dll to toolbox in one C# WinForms app target .NET 6.0; actually, I also tried this with C# Winforms app target .NET 5.0. The repo supported .NET 5.0, but if I install NUGET package: PM> Install-Package ConsoleControl -Version 1.3.0 I got warning like: Warning NU1701 Package 'ConsoleControl 1.3.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.

But if I just add reference to consolecontrol.dll in one C# WinForms project, when I open Forms Designer, and tried to add a new tab in toolbox, and choose items for toolbox, I can see the following message: The following controls were successfully added to the toolbox but are not enabled in the active designer. Even it seems not an error, but the result is: I can't see such item (custom control: consolecontrol) appear in toolbox, therefore, I can NOT drag and drop one onto Form1. Please advise, how can I fix this issue: The following controls were successfully added to the toolbox but are not enabled in the active designer? Thanks,

Steps to reproduce

Download file from: https://github.com/dwmkerr/consolecontrol.git Unzip it, and find consolecontrol.dll, then add reference to your WinForm project. Try to add it to Form Designer in Form1, inside toolbox, add new tab "ConsoleControl", then chosse items, browse to consolecontrol.dll file. Then click OK to add this custom control to toolbox in Form designer, you will see the information: The following controls were successfully added to the toolbox but are not enabled in the active designer

Diagnostics

No response

DRA6N commented 1 year ago

I second this, tried it by loading Krypton and it does the same thing, image

ElektroStudios commented 8 months ago

@ Klaus Loeffelmann [MSFT] | Aug 30, 2023 :

Currently, WinForms for .NET (5, 6, 7, 8) only supports Toolbox deployment of Controls, which are either part of the Solution or imported as a NuGet package. We are aiming for Visual Studio 2022 17.8 to have DLL-Reference Support for Controls/Toolbox Deployment. Until then, please use best practice, which is packing your Control Library as a NuGet Package which you then import in the respective WinForms projects.

Since 2021 until 2024. Don't expect a fix.

Full discussion: