C# error when trying to add an inherited component in Toolbox

Asked

Viewed 232 times

2

I am trying to create a component that inherits from a Combox. I created the component by following the steps below, the project is available at: https://dl.dropboxusercontent.com/u/74275347/ComponentesProprios.rar

  • No open project >File > New > Project > Class Library (Visual C#) > Name: "Components"
  • Delete Class1.Cs
  • In the project "Right click" > Add... > Component > Component Class (Visual C# Items) > Name: "Comboboxex"
  • In References > Add Reference... > Search for "Forms > Mark System.Windows.Forms > OK
  • In the "code" change Componentfor ComboBox > add using System.Windows.Forms; > in public ComboBoxEx() under InitializeComponent(); add DropDownStyle = ComboBoxStyle.DropDownList;
  • Save and "build"
  • In a Windowsformsapplication project I right click on a tab of "Tollbox" > Choose Items... > in the tab. NET Framework Components > click on Browse.. > I select "C: C# branches Repository Componentssums bin Debug Componentssums.dll"

This is when the message and error "There are no Components in 'C: C# Programming branches Repositorio Componentesproprios Componentesproprios bin Debug Componentesproprios.dll' appears that can be placed on the Toolbox."

Bomboboxex class using System; using System.Collections.Generic; using System.Componentmodel; using System.Diagnostics; using System.Linq; using System.Text; using System.Windows.Forms;

namespace ComponentesProprios
{
    public partial class ComboBoxEx : ComboBox
    {
        public ComboBoxEx()
        {
            DropDownStyle = ComboBoxStyle.DropDownList;
        }

        public ComboBoxEx(IContainer container)
        {
            container.Add(this);
        }
    }
}
  • 1

    There is a real need to develop the component in a dll the part?

  • 1

    The need is for the same component to be available for multiple projects

  • 1

    Benjamin, erase the class .designer which was created automatically and tries again.

  • I erased but the mistake was necessary

  • 1

    Did you recompile to create a new dll? I just tested it here and it worked

  • Yes, if you can send me the project. I even tried to delete the bin folder,

  • 1

    Dude, put the code where you create the components

Show 3 more comments

2 answers

2


According to some answers I saw in Soen the problem may be on itself Visual Studio and there are two things that have to be done to try to solve the problem.

  1. Right click on the Toolbox and then click on Reset Toolbox
  2. Instead of clicking on Choose items, try to drag the dll inside the Toolbox
  • Actually in Visual Studio 2013 onwards the function Choose items is with problems, but when I dragged the dll inside the tab of the tollbox worked smoothly.

0

Check that the version of . NET that made the components is compatible with the version of the project where you want to use them.

For example, do not create a component in . NET 4.5 and try to use it in an . NET 3.5 application.

  • 1

    I think your example phrase is backwards. The component cannot be from a version greater that the project itself.

  • 1

    Corrected, @Jéfersonbueno

  • They use the same version.

  • I retraced your steps the same, and I didn’t see any problem. The only difference I saw is that I’m using VS 2013, but your project is using VS 2015. I don’t know if anything’s changed in this new version.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.