Before invoking CreateToolWindow2 to create a new tool window, you should either move the User control (ControlObject) into the same assembly as the add-in, or set all of the attributes on the User control to make it fully visible to COM. (For example, checking the Register for COM interop option in the project's compile options.) If you do not do this, then the control will not marshal correctly and CreateToolWindow2 will return a null value.
If you attempt to set visibility states of the new tool window — such as height, width, or position — before the tool window is visible, you get an error. Make sure that the window is visible before attempting to set any such properties.
For more examples of how to use this method, see the ToolWindow sample on the Visual Studio Automation Samples Web page: http://www.microsoft.com/downloads/details.aspx?familyid=3ff9c915-30e5-430e-95b3-621dccd25150&displaylang=en. For information about creating ActiveX controls, see Creating an MFC ActiveX Control.