title: How to programmatically add a custom component to Visual Studio toolbox?
body: <p>I am creating an installer for a custom SSIS component that we have written. I would like to add the custom component automatically, rather than asking the user to manually add it.</p>
  
  <p>I'm trying to do this with this code:</p>
  
  <pre><code>public void AddToolboxItem(string toolboxTabName, string toolBoxItemName, string toolBoxItemPath) {
    Type dteReference;
    EnvDTE.ToolBox toolBox;
    EnvDTE80.ToolBoxItem2 addedToolBoxItem;
  
    // Get a reference to the visual studio development environment.
    dteReference = Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
  
    if(dteReference != null) {
      // Get a reference to the toolbox of the development environment.
      EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)Activator.CreateInstance(dteReference);
      toolBox = (EnvDTE.ToolBox)dte.Windows.Item("{B1E99781-AB81-11D0-B683-00AA00A3EE26}").Object;
  
      // Loop through all tab pages to find the toolbox tab page that was specified
      // in the toolboxTabName parameter.
      foreach (EnvDTE80.ToolBoxTab2 toolBoxTab in toolBox.ToolBoxTabs) {
  
        // Is this the right toolbox?
        if(string.Compare(toolBoxTab.Name, toolboxTabName, true) == 0) {
  
          // First check if the component is not already in the toolbox:
          bool found = false;
          foreach(EnvDTE80.ToolBoxItem2 toolBoxItem in toolBoxTab.ToolBoxItems) {
            if (string.Compare(toolBoxItem.Name, toolBoxItemName, true) == 0) {
              found = true;
              break;
            }
          }
  
          // The toolbox item is not in the toolbox tab, add it:
          if (!found) {
            addedToolBoxItem = (EnvDTE80.ToolBoxItem2)toolBoxTab.ToolBoxItems.Add(
              toolBoxItemName,
              toolBoxItemPath,
              EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
          }
          break;
        }
      }
    }
  }
  </code></pre>
  
  <p>I can get a reference to the "Data Flow Transformations" ToolBox Tab, but adding an item fails without an exception or error.</p>
  
  <p>I call this function with the parameters:</p>
  
  <ul>
  <li>toolboxTabName = "Data Flow Transformations"</li>
  <li>toolBoxItemName = "Special Test Component" </li>
  <li>toolBoxItemPath = "c:\Program Files\Microsoft SQL Server\100\DTS\PipelineComponents\mdTest.dll"</li>
  </ul>
  
  <p>As a sanity check, I tried using the vsToolBoxItemFormatDotNETComponent enumeration as Add()'s third parameter. This causes Add to return a valid object (ie, success), but the new item does not appear on the tool box. I suspect there is some sort of 'save' operation that may be necessary (even if I get the Add() to work properly).</p>
  
  <p>Is there any way to programmatically add a SSIS component to the
  toolbox?</p>