P
Pham Nguyen
I'm having problems creating an add-in to install a library of custom
controls I have in the toolbox. I've created a Visual Studio .NET
Add-in project and implemented this code in the OnConnection() method:
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
DTE env = (DTE)application;
// env.ExecuteCommand("View.PropertiesWindow", String.Empty);
Window win =
env.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
ToolBox tb = (ToolBox)win.Object;
ToolBoxTabs tbts = tb.ToolBoxTabs;
ToolBoxTab tbt = tbts.Add("My Tab");
tbt.Activate();
tbt.ToolBoxItems.Add("", @"D:\Controls\MyControls.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
tbt.ToolBoxItems.Add("My Text Item", "My Text...",
vsToolBoxItemFormat.vsToolBoxItemFormatText);
}
The text item gets added just fine, but none of the controls get
loaded (if I put in a bogus path for the controls DLL, though, I do
get an error). I read about a possible bug in VS.NET where controls
will not get added if the Properties window isn't open, but when I
uncomment the line in the code above that does that, I get a "Not
enough storage is available to complete the operation" error. Is there
something off about the code above?
controls I have in the toolbox. I've created a Visual Studio .NET
Add-in project and implemented this code in the OnConnection() method:
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
DTE env = (DTE)application;
// env.ExecuteCommand("View.PropertiesWindow", String.Empty);
Window win =
env.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
ToolBox tb = (ToolBox)win.Object;
ToolBoxTabs tbts = tb.ToolBoxTabs;
ToolBoxTab tbt = tbts.Add("My Tab");
tbt.Activate();
tbt.ToolBoxItems.Add("", @"D:\Controls\MyControls.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
tbt.ToolBoxItems.Add("My Text Item", "My Text...",
vsToolBoxItemFormat.vsToolBoxItemFormatText);
}
The text item gets added just fine, but none of the controls get
loaded (if I put in a bogus path for the controls DLL, though, I do
get an error). I read about a possible bug in VS.NET where controls
will not get added if the Properties window isn't open, but when I
uncomment the line in the code above that does that, I get a "Not
enough storage is available to complete the operation" error. Is there
something off about the code above?