Click here to Skip to main content
15,072,051 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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;
          }      //If tab doesn't exist, creating new one
          if (null == MyTab)
              MyTab = VSToolBox.ToolBoxTabs.Add(TabName);
          ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser",
              @"MyComponents.FileBrowser, MyTestComps, Version=, Culture=neutral, PublicKeyToken=2283de3658476795",

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.
ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser",
Updated 12-May-11 18:08pm
BobJanova 12-May-11 8:07am
Is the MyTestComps assembly where VS can see it?

Also, this doesn't seem like the right way to add things.
Chil Umez 12-May-11 8:20am
YES its in GAC
I tried giving the path where dll file is stored, even that didn't work
If this is not the right way please suggest the correct one
BobJanova 12-May-11 13:54pm
Either with a VS plugin or by adding it in the IDE yourself, I think. I was expecting there to be an auto-searched repository like SharpDevelop has but a quick search didn't find one.

1 solution

Its working fine, If I run the application with administrator rights.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900