Installing Managed ToolBox Controls Programmatically
In the past with Visual Studio 2003, it was possible to programmatically add .Net or Managed toolbox controls using the DTE. With Visual Studio 2005 this method of programmatically adding the controls has been deprecated in favor of using one of the following two methods:
1. Visual Studio Content Installer
2. Tools.InstallCommunityControls command.
The difference between the two is that one is an external program that can install all kinds of community content such as addins, macros, snippets etc and the other is a built in command.
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/ms246580.aspx
Using the Tools.InstallCommunityControls command
You can use this command to add custom toolbox controls either from within Visual Studio or from the command line. For either case you need to follow the steps outlined below to install the controls.
Copy the controls to the My Documents\Visual Studio 2005\Controls\<companyname>\ folder. The <companyname> is used as the name of the tab which will contain controls.
For command line installation:
Open the Visual Studio Command prompt and execute the following command:
devenv /command Tools.InstallCommunityControls
For installation from within Visual Studio:
Open the Command Window (View->Other Windows->Command Window) and execute the following command: Tools.InstallCommunityControls.
Having the ability to execute a command from the command line can be very useful in creating install scripts and a batch file such as the one below can install the community controls.
@echo off
set TabName=%1
set DllName="%2"
set ControlsFolder="%userprofile%\My Documents\Visual Studio 2005\Controls\%TabName%"
%ControlsFolder%
mkdir %ControlsFolder%
copy %DllName% %ControlsFolder%
"%VS80COMNTOOLS%\..\IDE\devenv.exe" /command Tools.InstallCommunityControls
set TabName=
set DllName=
set ControlsFolder=
Another way to do this using DTE is to use DTE.ExecuteCommand:
DTE2 dte;
dte = (DTE2)Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.8.0"));
dte.ExecuteCommand("Tools.InstallCommunityControls", "");
dte.Quit();
One thing to note is that this mechanism does not fit well if you have folder redirection and some more work in terms of setting right permissions etc is required.