W
wisekat
Guest
We have a utility written in C# that automates creation of component icons on the Visual Studio Toolbox. The core part of code looks like this:
EnvDTE.Window myToolBoxWindow = myDTE.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
EnvDTE.ToolBox myToolBox = (EnvDTE.ToolBox)myToolBoxWindow.Object;
#region Create or recreate the tab
EnvDTE.ToolBoxTab myTab;
try
{
myTab = myToolBox.ToolBoxTabs.Item(tabName);
myTab.Delete();
myTab = null;
}
catch
{
myTab = null;
}
if (myTab == null)
myTab = myToolBox.ToolBoxTabs.Add(tabName);
myTab.Activate();
#endregion
#region Add the library to the tab
EnvDTE.ToolBoxItem myToolBoxItem;
foreach (string myLibPath in libPaths)
myToolBoxItem = myTab.ToolBoxItems.Add(tabName, myLibPath, EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
#endregion
This code has been working for years since the times of VS 2005, but it no longer works reliably. It seems, problems started with the release of VS 2019. Sometimes this code creates only an empty Toolbox tab with the specified name, sometimes the code simply does nothing - though it is executed without any exceptions.
What could be the reason of this behavior? Does the result of this code execution depends on the installed VS or OS components?
Continue reading...
EnvDTE.Window myToolBoxWindow = myDTE.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
EnvDTE.ToolBox myToolBox = (EnvDTE.ToolBox)myToolBoxWindow.Object;
#region Create or recreate the tab
EnvDTE.ToolBoxTab myTab;
try
{
myTab = myToolBox.ToolBoxTabs.Item(tabName);
myTab.Delete();
myTab = null;
}
catch
{
myTab = null;
}
if (myTab == null)
myTab = myToolBox.ToolBoxTabs.Add(tabName);
myTab.Activate();
#endregion
#region Add the library to the tab
EnvDTE.ToolBoxItem myToolBoxItem;
foreach (string myLibPath in libPaths)
myToolBoxItem = myTab.ToolBoxItems.Add(tabName, myLibPath, EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
#endregion
This code has been working for years since the times of VS 2005, but it no longer works reliably. It seems, problems started with the release of VS 2019. Sometimes this code creates only an empty Toolbox tab with the specified name, sometimes the code simply does nothing - though it is executed without any exceptions.
What could be the reason of this behavior? Does the result of this code execution depends on the installed VS or OS components?
Continue reading...