locked
Problem in adding user controls to toolbox programatically RRS feed

  • 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);

     


    • Moved by eryang Friday, May 13, 2011 2:46 AM (From:Building Development and Diagnostic Tools for .Net)
    • Edited by umez Chil Friday, May 13, 2011 4:05 AM
    Thursday, May 12, 2011 12:07 PM

Answers

All replies