Hiding dynamically added toolbar will crash ArcGIS desktop 10.1 on XP

Discussion created by gkar68 on Mar 20, 2013
I have weird bug

If you create dynamically a toolbar on ArcGIS Desktop extension, and then try to hide it . It will crash Desktop 10.1 on Windows XP.
But work find on Windows 7.

So, for example this simple code for Desktop extension.

on the Startup event write this simple code

public void Startup(ref object initializationData)
            m_application = initializationData as IApplication;

            if (m_application == null)

            var commandBars = m_application.Document.CommandBars;
            var myToolbar = commandBars.Create("My First toolbar", esriCmdBarType.esriCmdBarTypeToolbar);
   //Find my own personal command
   var uid = new UIDClass();
            uid.Value = "{057234a3-d67b-4b84-9781-4e2d028d51c9}"; // or any registered command in desktop
   // you can replace it with any built-in desktop command
            var command = commandBars.Find(uid, false, false);
            object outme = null;
            myToolbar.Add(uid, ref outme);

            var standardUid = new UIDClass(); //find the standard toolbar to dock it to it
            standardUid.Value = "esriArcMapUI.StandardToolBar";
            var stndToolbar =     commandBars.Find(standardUid, false, false) as ICommandBar;
            myToolbar.Dock(esriDockFlags.esriDockRight, stndToolbar);

You can put that code anywhere you want, and not necesserly an extension startup.
Now. if you try to hide the toolbar, with right-mouse click on the toolbar area, and uncheck the toolbar.
The desktop will crash on XP.