How to add custom control to Visual Studio 2005 Toolbox?

Hi all,

I am working on a Windows Forms custom control now and I would like to place my control right on the Toolbox window after installation, however, this seems to be a problem now.

I notice that EnvDTE and EnvDTE80 namespace and the DTE2 interface seem to provide customization of VS IDE environment, and I tried as follows:

1> Get a DTE2 instance by Activator;
2> Use DTE2.ToolWindows.ToolBox.ToolBoxTabs.Add to add a new tab;
3> Use ToolBoxTab.Add(name, object, vsToolBoxItemFormat) to add my control. here name="Control1", ie, and object=@"C:\Control1.dll" as mentioned in MSDN.

Here is the problem. this method should return a ToolBoxItem reference, however, a null is returned and nothing was added in the toolbox.

Will someone please help me out
Thanks a lot and a lot.


Answer this question

How to add custom control to Visual Studio 2005 Toolbox?

  • Steve Nunez

    Woo, new problem encountered.
    At first this Tools.InstallCommunityControls works all right, however, when I try it again using devenv /command Tools.InstallCommunityControls, the following error pops up:

    Package Load Failure

    Package 'ToolBox Control Installer Package' has failed to load property (GUID = {36839529-3AF3-47FA-8194-F4A3FA9F0ED7}). Please contact package vendor for assistance. Application restart is recommended, due to possible environment corruption. Would you like to disable loading this package in the future
    You may use 'devenv /resetskippkgs' to re-enable package loading.

    How is that happening And what shall I do if I do not want to have my Visual Studio reinstalled

    Thanks a lot!


  • Operator10

    Chetan,

    I have a more serious problem.  I cannot get Tools.InstallCommunityControls to work under any version of the RTM.  A number of other posters have also encountered the same difficulty.  Yet, I notice that you continue to maintain that this command works just fine on the RTM version.

    A post from Jeffrey Liu (who had earlier difficulties getting the command to work) gave me some clues about what may be happening.  On November 10, he posted:
     
    I uninstalled and reinstalled VS2005, and now the command "Tools.InstallCommunityControls" works.  Woohoo!

    After reading this post, I did some investigation.  I walked around our office and looked at all of the machines that had the RTM version of VS 2005 installed, and investigated whether any of the machines were able to invoke Tool.InstallCommunityControls.  There was only one machine (out of 6) which was able to do this, and this machine was a machine that originally had RC1 installed and then uninstalled before installing the RTM version.  All other machines were installed from scratch.

    I wonder if what may be happening is that if you start from a Beta version or the RC1 version of VS 2005, you will have a working Tools.InstallCommunityControls.  If you then uninstall, there will still be some pieces of Tools.CommunityControls left so that if you then install the RTM, you will still be able to use the Tools.InstallCommunity Controls command.  However, if you install the RTM on a clean machine, you will be out of luck.

    BTW, I should mention that I used the RC1 version a few weeks ago and had no problems with the Tools.InstallCommunityControls command.

    David

  • StefanS

    Hi Jeffrey,

    No currently there is no way to install community controls for all the users. We may be able to provide something in the future but canot promise anything. Currently each individual user has to install the controls.

    Thanks,
    Chetan

  • Lightning Lord

    I can't find a registry element with that name.
    I found HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\.
    However, there isn't a UserToolBoxControls element.  There is a Toolbox folder, then a VB Editor folder.

    Also, should the command Tools.InstallCommunityTools work   How can I get it to work

    I'm basically looking for a way to programmatically add my control to the toolbox such that no user input is required.

  • Jon D.

    David,

    As part of our testing process we install the bits on a freshly imaged machine and so we are doing what you are doing. In fact I once again tried the following and was not able to repro the package load failure as easily as some of you have been reporting. I have been trying to get a good repro on the load failure but have not been able to get one.

    1. Install OS and VS 2005 from scratch
    2. Create a 2 Toolbox control dlls and 1 vsi file
    3. Install the Toolbox controls using Tools.InstallCommunityControls from within VS and from the commandline.
    4. Install the toolbox control from the VSI

    All my community control install steps were successful.

    On a separate thread, Harry CC, has found that he had SQL Express Management Studio installed that started giving him Package Load Failures. I am currently looking into this issue.
    So if you have the Management Studio installed then that might be the reason why you are seeing package load failure.

    Thanks,
    chetan



  • Chetan Singh

    Should this work for RTM  

    The method of using Tools.InstallCommunityControls does not work.

    I'm trying the content installer, and it worked for installing an item template, but it failed to install a control.

    This is the process that I went through:
    1. I made MyControl.dll that contained three controls.  (A component, a control, and a user control.)
    2. I ran the content builder and included MyControl.dll in the Toolbox Controls section.
    3. I created the .vsi file.
    4. I ran the .vsi file, but when it was installing the controls, the IDE opened and displayed the following error message: Command "Tools.InstallCommunityControls" is not valid.

    Here is the content of my .vscontent file:
    <VSContent xmlns="http://schemas.microsoft.com/developer/vscontent/2005">
      <Content>
        <FileContentType>Toolbox Control</FileContentType>
        <Description>My Toolbox Control Content</Description>
        <DisplayName>My Toolbox Control Content</DisplayName>
        <ContentVersion>1.0</ContentVersion>
        <FileName>My Tab\MyControl.dll</FileName>
      </Content>
    </VSContent>

    Does anybody know what I'm doing wrong

    Basically, I am looking for a way to programmatically add controls to the VS2005 toolbox.

    Thanks a bunch.
    - Jeffrey Liu


  • da_cobra

    This happens if you have manually deleted user added tabs. An easy workaround for this is to delete all values under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\UserToolBoxControls and then run the command again.

    LMK if this works. We are investigating this issue further.



  • subrama6

    Harry,

    You cannot add Managed Controls to the Toolbox using the above mentioned method. The best and the recommended way is described in my blog entry (http://blogs.msdn.com/chetanc/archive/2005/10/05/477128.aspx).

    LMK if you have any further questions.

    Thanks,
    Chetan

  • Ruepen

    Chetan,

    Thanks for the quick response.  Here is some more information:

    Using the instructions from your WebLog,

    For installation from within Visual Studio:
    Open the Command Window (View->Other Windows->Command Window) and execute the following command: Tools.InstallCommunityControls


    I cannot get Tools.InstallCommunityControls to work.  I always get the response:

    Command "Tools.InstallCommunityControls" is not valid

    For your information, this is what I have on my machine:

    Microsoft Visual Studio Team SUite Version 8.0.50727.42 (RTM.050727-4200)
    Microsoft .NET Framework Version 2.0.50727
    Microsoft SQL Server 2005 Community Technology Preview
    Microsoft SQL Server Management Studio Version 9.00.1314.00

    I'd also like to know why there is no mention of Tools.InstallCommunityControls any place on the entire internet other than this forum and your own WebLog.

    In your WebLog, you say that you can get more information on the Visual Studio Content Installer by following the below link. 

    Using Visual Studio Content Installer
    This executable, VSContentInstaller.exe, is available under \Program Files\Common Files\Microsoft Shared\MSEnv. The input for this executable is a VSI file. More information on this is available here:
    http://msdn2.microsoft.com/en-us/library/ms151097(en-US,VS.80).aspx

    Trying this link results in "Content Not Found".  Do you have an alternate link

    David


  • KesPeti

    That helps, Thanks a lot!


  • Graham Harrison

    Hi Chetan,

          I'm working in VS.NET 2003.

    Need to add a particular control from a dll to the toolbox. I'm able to add/Remove a tab to and from the toolbox. I'm also able to remove a Toolbox Item by specifying its name and also able to add all the controls in that dll.

    Help Me!

  • Bob McD

    I uninstalled and reinstalled VS2005, and now the command "Tools.InstallCommunityControls" works.  Woohoo!

    Is there any way to install a control for all users

  • Paul B

    Could it be that I don't have the key because my control extends from Component rather than UserControl

    Yes, I tried installing the Toolbox controls from within Visual Studio as outlined in your post.  Again, the command Tools.InstallCommunityControls does not work for me.

    I believe I'm using RTM.  My About window says: "Microsoft Visual Studio 2005 Version 8.0.50727.42 (RTM.050727-4200)". 

    By the way, FYI, I am able to manually add the Component to my toolbox.

    Thanks for sticking with this ;)
    - Jeff

  • ConradsW

    Hmm... That key is created if you have some UserToolBox controls installed.

    Did you try installing the Toolbox controls without using the Content Installer maybe from within Visual Studio as outlined in my post

    As for the command, it works with RTM.

    Thanks,

    Chetan

     



  • How to add custom control to Visual Studio 2005 Toolbox?