question

BenTam avatar image
0 Votes"
BenTam asked BenTam commented

Failed to load toolbox item 'Label'

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();
         }
     }
 }



dotnet-csharp
removed.gif (22.1 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@BenTam, Welcome to Microsoft Q&A, based on my test, it works well for me. Could you tell me which template you used for the BaseControlLibrary class? I used the following template:
241401-image.png


0 Votes 0 ·
image.png (8.0 KiB)
BenTam avatar image BenTam JackJJun-MSFT ·

Hi @JackJJun-MSFT

The template that I used is "Windows Forms Control Library (.NET Framework)".

0 Votes 0 ·
BenTam avatar image BenTam JackJJun-MSFT ·

Hi @JackJJun-MSFT

Any new ideas about my question?



0 Votes 0 ·

@BenTam, Sorry for the late response, I think that maybe that our Control library is different. Could you upload your project to github and share the link here?

0 Votes 0 ·
Show more comments

1 Answer

JackJJun-MSFT avatar image
0 Votes"
JackJJun-MSFT answered BenTam commented

@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.









image.png (7.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JackJJun-MSFT

Thanks for your reply. It works!

0 Votes 0 ·