Adding IToolbarDef to a toolbar control

Discussion created by dbrandon on Aug 7, 2012
Hey all: 

I am converting some code developed for ArcGIS 9.x to ArcGIS 10.  It deals with adding a collection of toolbars to a toolbar control that is added to a stand alone application.  The original code looks something like this:

UID uid = new UIDClass();

for (int i = 0; i < toolbarList.Count; i++)
                uid.Value = toolbarList[i].progid;

                AxToolbarControl toolbarCtrl = new AxToolbarControl();
                ((System.ComponentModel.ISupportInitialize)(toolbarCtrl )).BeginInit();
                toolbarCtrl .Margin = new System.Windows.Forms.Padding(4);
                ((System.ComponentModel.ISupportInitialize)(toolbarCtrl )).EndInit();

               toolbarCtrl.AddToolbarDef(uid, -1, true, 4, esriCommandStyles.esriCommandStyleIconOnly);

        catch(Exception ex)
               MessageBox.Show("Cannot add toolbar [" + toolbarList[i].progid.ToString() + "]");

With 9.3 this code would work but now it is not.  I don't know if the problem is with this code or the first toolbar (I have only converted the first one) itself however, I am able to pull the toolbar into ArcMap 10 and it displays just fine.  If I take the first two commands from the toolbar in question and add them using toolbarCtrl.AddItem(item), the toolbar loads just fine.

Any ideas that might get this going again?