Failed to load toolbox item 'Label'

BenTam 1,541 Reputation points
2022-09-15T05:21:57.293+00:00

Hi All,

I create a BaseControlLibrary.csproj and try to subclass all controls. However, when I move my user control 'Label' to a form. Visual Studio tells me that

"Failed to load toolbox item 'Label'. It will be removed from the toolbox."

241285-removed.gif

Label Source Code

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
using System.Windows.Forms;  
  
namespace BaseControlLibrary  
{  
    public partial class Label : UserControl  
    {  
        public Label()  
        {  
            InitializeComponent();  
        }  
    }  
}  
  
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,190 questions
{count} votes

Accepted answer
  1. Jack J Jun 24,276 Reputation points Microsoft Vendor
    2022-09-22T07:46:12.747+00:00

    @BenTam , you could try the following steps to solve the unloaded problem first of all.

    1. Please open your NewTims.csproj and find the line 69.
    2. Please add the closed tag </Compile to the correct place. <Compile Include="BaseForm.Designer.cs">
      <DependentUpon>BaseForm.cs</DependentUpon>
      </Compile> -> Please add it
    3. Please open the solution NewTims and you find NewTims is normal.

    243764-image.png

    Also, I find some errors when I rebuild the solution, you could make some changes.

    First, Please add using Library; in the Student_Form class.

    Second, Please add another parameter to avoid the error:

       Surname_textBox.Text = Lib.Item(s_Name, 1,"");  
       GivenName_textBox.Text = Lib.Item(s_Name, 2,"");  
    

    Then, the project will rebuild without the problem.

    As for the question Failed to load toolbox item 'Label', based on my test, I could not reproduce the problem. When I drag the label , button and label from the toolbox to the BaseForm, it will not show any errors.

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful