adding Icon to outlook AddOn ToolBar?


I have problem to add Icon to outlook add-on toolbar.
I'm using visual studio 2005 SE and outlook 2003 with the following code.
when I try to assign the image to the button it crash with:
{"Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"}

any idea why?
the same code working on outlook 2007...

Thanks, Tom
CommandBars cmdbrs = tInspector.CommandBars;

                toolbarButton = (CommandBarButton)cmdbrs["Standard"].Controls.Add(1, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                toolbarButton.Caption = "Test";
                toolbarButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
                toolbarButton.TooltipText = "Publish";
                toolbarButton.Visible = true;
                toolbarButton.Picture = getImage();
                toolbarButton.Mask = getImage();
                toolbarButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(OnToolbarButtonClick);

private stdole.IPictureDisp getImage()
            stdole.IPictureDisp tempImage = null;

                System.Drawing.Icon newIcon =

                ImageList newImageList = new ImageList();
                tempImage = ConvertImage.Convert(newImageList.Images[0]);
            catch (Exception ex)
            return tempImage;

    sealed public class ConvertImage : System.Windows.Forms.AxHost
        private ConvertImage()
            : base(null)
        public static stdole.IPictureDisp Convert
            (System.Drawing.Image image)
            return (stdole.IPictureDisp)System.

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TomDromiAuthor Commented:

Most of these pages just repeat my code...

Any Other Idea of the exception?

Thanks, Tom
Miguel OzSoftware EngineerCommented:
are you using this in the main thread context?
The code above does not work in a thread, it gets unexpected behaviour including a crash.
TomDromiAuthor Commented:
finally, I use the faceId property  to place an Icon from the built-in library.
I used a temp function to make 1000 button with all the available icons and I choose the one most appropriate.

Thanks for the advices.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.