Creating a ToolWindow hosting a .NET user control
In previous version of VS, if you want to create a ToolWindow hosting a .NET user control by using Windows.CreateToolWindow, you'll have to use a shim control to support it. Now with VS 2005, you don't need the shim any more. It is so handy by using Windows2.CreateToolWindow2, you pass the assembly location and the class name, you are able to host your .NET user control in the ToolWindow you created.
Following is a C# code snippet showing how to implement this in an add-in:
Windows2 win = (Windows2)_applicationObject.Windows;
object ctl = null;
Guid g = Guid.NewGuid();
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Window myToolWin = win.CreateToolWindow2(_addInInstance, asm.Location, "MyToolWin.UserControl1", "My Tool Window", "{" + g.ToString() +"}", ref ctl);
myToolWin.Visible = true;
One thing I want to point it out is when the User Control is not in the same assembly as the add-in, CreateToolWindow2 does not return a reference to the user control (ctl is null). You either need to move the control into the same assembly as the Add-in, or set all the attributes on the control to make it fully COM visible. Also, to make the ToolWindow show up, you need to set myToolWin.Visible = true.