2011-05-12 6 views
3

Salut J'essaie d'ajouter un nouvel onglet et mes commandes à programatically visual studio 2010.problème à ajouter à l'utilisateur contrôle boîte à outils programatically

Son onglet création mais son ne pas ajouter les commandes à l'onglet.

 //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(); 

Si j'exécuter en tant qu'administrateur de son travail fine, en ajoutant des contrôles pour contrôler la bibliothèque, mais lorsque je tente d'ajouter la bibliothèque qui est pas dans son GAC ne fonctionne pas. Cela ne fait aucune exception. Ex:

ToolBoxItem tbi = MyTab.ToolBoxItems.Add("FileBrowser", 
    @"C:\MyComponents\MyTestComps.dll", 
    vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent); 

Répondre

Questions connexes