Hi I'm trying to add a new tab and my controls programatically to visual studio 2010.
Its creating tab but its not adding the controls to tab.
//Getting design time environment
DTE DesignTimeEnvironment = (DTE)Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.10.0"), true);
//Getting tool box object
ToolBox VSToolBox = (ToolBox)DesignTimeEnvironment.Windows.Item("{B1E99781-AB81-11D0-B683-00AA00A3EE26}").Object;
ToolBoxTab MyTab = null;
string TabName = "MyComponents";
//checkin if Tab already exists
foreach (ToolBoxTab VSTab in VSToolBox.ToolBoxTabs)
{
if (VSTab.Name == TabName)
{
MyTab = VSTab;
break;
}
}
//If tab doesn't exist, creating new one
if (null == MyTab)
MyTab = VSToolBox.ToolBoxTabs.Add(TabName);
MyTab.Activate();
ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser",
@"MyComponents.FileBrowser, MyTestComps, Version=1.0.0.1, Culture=neutral, PublicKeyToken=2283de3658476795",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
DesignTimeEnvironment.Quit();
If i run as administrator its working fine, adding Controls to control library, but when I try to add the library which is not in GAC its not working. It doesn't through any exception. Ex:
ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser",
@"C:\MyComponents\MyTestComps.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
It is working fine with the above code. The only problem was I have to run the application as administrator rights. Even this way also it is working.
or http://blogs.msdn.com/b/quanto/archive/2009/06/12/how-do-i-deploy-a-toolbox-control-as-a-vsix.aspx