This article presents a console application that allows to create or delete a ToolBox tab and fill it with components of one or more assemblies. This article extends the Serkan Inci article (although I’ve not started from his code, I’ve found there the trick of activating a Property window).
The generated EXW file can be easily run from any installer, hiding its command window.
Basic familiarity with Visual Studio .NET and C# is necessary for this article. Experience on DTE and Reflection is a plus.
Using the code
To use the EXE file to install a DLL, simply launch:
ElToolBoxInstaller.exe -i TabName FirstDllFullPath
[SecondDllFullPath] [ThirdDllFullPath] ….
Note that you have to pass the assembly's full path.
To use the EXE file to delete a tab, simply launch:
ElToolBoxInstaller.exe -u TabName
Design specifics are that:
- All components of an assembly are going to be installed on the same tab.
- With a single command it is possible to install components from multiple assemblies under the same tab.
- Visual Studio will be closed during installation (the software checks for this).
- All versions of Visual Studio have to be updated.
About point 1, I will probably update the code to allow to send components of the same assembly to different tabs (it wasn’t necessary for my products till now, but I think there’s an easy way of installing all components to a tab and then moving them).
Point 2 is important to avoid reopening a DTE several times.
Point 3 is a limitation that helps to prevent bad results and unnecessary complications (you could easily update code to link an open Visual Studio instance, but you should update the ToolBox of all instances and I’ve found some strange effects when the development environment was in debug mode).
First of all the program checks if a Visual Studio instance is running, looking for a "devenv" process.
private static bool IsVSActive()
Process processArray1 = Process.GetProcesses();
for (int num1 = 0; num1 < processArray1.Length; num1++)
Process process1 = processArray1[num1];
if (string.Compare(process1.ProcessName, "devenv",
true, CultureInfo.InvariantCulture) == 0)
catch (Exception e)
Once verified that no VS instance is running, the program proceeds.
The higher level function is
InstallOnVs, it receives as argument a ProgId string (for example: “VisualStudio.DTE.7.1” for Visual Studio 2003) and an array of strings that must contain:
- –i (to install) or –u (to uninstall)
- tab name
- one or more assembly full paths
InstallOnVs first creates a ToolBox window:
Type type1 = Type.GetTypeFromProgID(progId);
if (type1 == null) return;
dte1 = (DTE) Activator.CreateInstance(type1);
Window window1 = dte1.Windows.Item(Constants.vsWindowKindToolbox);
box1 = (ToolBox) window1.Object;
private static void tabActivate()
Finally all assemblies are loaded using
private static void AddToToolBox(string assemblyfullpath)
FileInfo info1 = new FileInfo(assemblyfullpath);
catch (Exception e)
Although the task is not so complex I wasn’t able to find a “ready to go” solution, I hope now this will save your time.
First version submitted - 07 September 2005.