Answered by:
Problem in adding user controls to toolbox programatically

Question
-
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 whwn I use to add the library which is not in GAC its not working. It doesn't theough aany exception.
Ea:
ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser",
@"C:\MyComponents\MyTestComps.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
Thursday, May 12, 2011 12:07 PM
Answers
-
Please try this method instead: http://blogs.msdn.com/b/quanto/archive/2009/06/12/how-do-i-deploy-a-toolbox-control-as-a-vsix.aspx
-Josh Stevens
VS Shell team
- Proposed as answer by Ryan MoldenMicrosoft employee Saturday, May 14, 2011 4:31 AM
- Marked as answer by Victor_Chen Wednesday, May 25, 2011 8:54 AM
Saturday, May 14, 2011 3:36 AM
All replies
-
Move to VS Extenstion forum for better support.
Eric Yang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, May 13, 2011 2:45 AM -
Please try this method instead: http://blogs.msdn.com/b/quanto/archive/2009/06/12/how-do-i-deploy-a-toolbox-control-as-a-vsix.aspx
-Josh Stevens
VS Shell team
- Proposed as answer by Ryan MoldenMicrosoft employee Saturday, May 14, 2011 4:31 AM
- Marked as answer by Victor_Chen Wednesday, May 25, 2011 8:54 AM
Saturday, May 14, 2011 3:36 AM