Search code examples
c#winformscomponentsvisual-studio-2003iextenderprovider

Winforms C# - Legacy Project Visual .NET 2003: Custom Extender Provider not shown in Toolbox


I have created a custom Extender Provider to apply to all my labels: a class that inherits from Component and implements IExtenderProvider.

It compiles correctly without errors. Then I go to Toolbox but it is not shown.

I have restarted VS and it does not work. Also I have created this extender provider class within another separate assembly, compile it and then added a reference to the other assembly where I want to use it as explained here but without success, it says:

the class needs to be packaged into a separate assembly from the assembly using it.

Any ideas what's going on?


Solution

  • Finally I have solved by following below steps:

    1. In a separate assembly (not the same where you are using it), a class library project, create a class and implement your extender provider there. Make this class to inherit from System.ComponentModel.Component and implement IExtenderProvider.
    2. Once implemented, compile it. You will obtain your dll.
    3. Add a reference in the assembly where you are using it that points to the class library which contains your extender provider.
    4. To make visible your extender provider in the Toolbox, do right button mouse click and in context menu select "Add/Remove Items...", Customize Toolbox dialog window will be shown.
    5. In Customize Toolbox dialog window you will see two tabs ".Net Framework Components" and "COM Components". In ".Net Framework Components" click on browse button and navigate to the place where your dll (class library containing your extender provider) is and select it.
    6. After that, you will see immediately your extender provider appears listed on ".Net Framework Components", select it and ensure it is checked, and click on 'OK' button. That's all, now your extender provider will be shown in toolbox under "Components" group.
    7. Now, open a winform (in design view) from your assembly on which you want to insert your extender provider and drag and drop your extender provider to the form.
    8. Select an object of your form, one that your extender provider is created for, and go to its properties, there you will see the new properties implemented in your extender provider for that component. If you did not specify a category attribute in your extender provider property, it will be shown under "Misc" category in the properties window.

    That's all.

    It seems like in older versions of Visual Studio, like Visual .NET 2003, extender providers are not automatically added to the toolbox and you must do manually. In newer versions of Visual Studio such as 2015 (I have tested), it is automatically done for you.