views:

84

answers:

1

I've a VS add-in that creates a toolbar and displays it (based on previous visibility settings) when VS launches. The add-in works fine in VS 2005 and 2008 but in 2010, the toolbar is only visible while VS is loading.

Once VS has completed loading, the toolbar disappears.

I can replicate the sample problem with the Alpha Blend code sample: http://code.msdn.microsoft.com/AlphaBlendToolbar

To reproduce: Register the add-in and configure it to start when VS starts. Close VS and re-open it. The toolbar is visible for a few moments and it then disappears!!

A: 

As it turns out, the problem is with setting the visibility of the toolbar too early. When you delay setting the visibility until the toolbar is completely configured, then it works in VS 2010 - which is strange as the same code worked fine in VS 2003, VS 2005 and VS 2008!

Anyway, to keep the toolbar visible in the AlphaBlend code sample, comment out the toolbar configuration lines as below:

CommandBar toolbar = commandBars.Add("AlphaToolbar", MsoBarPosition.msoBarTop, System.Type.Missing, true);
//toolbar.Visible = true;
//toolbar.Enabled = true;

And reinstate them after the controls have been added to the toolbar:

commandOmega.AddControl(toolbar, 2);
toolbar.Visible = true;
toolbar.Enabled = true;

Thanks to NeelimaM for helping to spot this over on the MSDN Code Gallery site.

Catch22