I am currently writing some internal components to be used in our C#
projects. I was wondering if there's any documented way of adding them
to the VS.NET IDE's toolbox.
How can I install components onto another developer's machine? Yes, I
know, I need to copy the assemblies, probably into the GAC, right?
But how can I add these assemblies to a given (newly created) tab on
their toolbox? I'd like to do this for them, in the install, so that
everyone has the same component tabs.
Also, if I have a .CHM describing these components (created by NDoc),
is there any way of automatically merging this help file into the
VS.NET IDE's help system?
Any hints would be most welcome!
Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
I've been struggling with the same thing. I have not
solved this problem completely, so if you do, please let
me know.
There are two aspects to this problem. The first is
installing into VS.NET. There are 3 ways this is done 1)
Macros, 2) Add-Ins, 3) Packages (search for VSIP on
MSDN.Microsoft.com). The second is manipulating the
ToolBoxTabs and ToolBoxItems collections (see these in the
on-line help for sample code).
My next step is to move my test code (which acts like it
works, but nothing is visible) into the Add-In and see if
the code works when the Add-In is loaded (vs just running
it). Also, I don't quite understand how VS.NET decides
which tabs should be made visible based on the type of
object (form, code, etc.) currently displayed - this might
be a factor in why my tabs are not showing (even with view
all selected).
Please let me know what you find.
Ciao, Mike.
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using EnvDTE;
using System.Windows.Forms;
using System.IO;
namespace MyControls
{
/// <summary>
/// Summary description for MyAssemblyInstaller.
/// </summary>
[RunInstaller(true), DesignTimeVisible(false), ToolboxItem(false)]
public class MyAssemblyInstaller : System.Configuration.Install.Installer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MyAssemblyInstaller()
{
// This call is required by the Designer.
InitializeComponent();
}
public override void Install(IDictionary savedState)
{
base.Install(savedState);
string installPath = (string)Context.Parameters["InstallPath"];
// Install toolbox items and tabs for My Controls
DTE devEnv = new DTEClass();
// Make sure the properties window is visible. This gets around a VS.Net bug when installing
// toolbox icons
devEnv.ExecuteCommand("View.PropertiesWindow", string.Empty);
// Get the list of toolbox tabs
Window win = devEnv.Windows.Item(Constants.vsWindowKindToolbox);
ToolBox tb = (ToolBox)win.Object;
ToolBoxTabs toolBoxTabs = tb.ToolBoxTabs;
// Delete the "My Controls" tab if it already exists
foreach (ToolBoxTab t in toolBoxTabs)
{
if (t.Name == "My Controls")
t.Delete();
}
// Add the "My Controls" tab
ToolBoxTab myToolboxTab = toolBoxTabs.Add("My Controls");
myToolboxTab.Activate();
installPath = Path.Combine(installPath, "MyAssemblyName.dll");
// Add controls to the "My Controls" tab
myToolboxTab.ToolBoxItems.Add("MyComponentName", installPath,
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
devEnv.Quit();
devEnv = null;
}
public override void Uninstall(IDictionary savedState)
{
if (savedState != null)
{
base.Uninstall(savedState);
// Uninstall toolbox items and tabs for My Controls
DTE devEnv = new DTEClass();
// Get the list of toolbox tabs
Window win = devEnv.Windows.Item(Constants.vsWindowKindToolbox);
ToolBox tb = (ToolBox)win.Object;
ToolBoxTabs toolBoxTabs = tb.ToolBoxTabs;
// Delete the "My Controls" tab if it already exists
foreach (ToolBoxTab t in toolBoxTabs)
{
if (t.Name == "My Controls")
t.Delete();
}
devEnv.Quit();
devEnv = null;
}
}
...