[Solved] Exception Handling when using the ribbon

Apr 9, 2010 at 12:05 PM

First of all nice project!

Thanks for the author.


I do see major issue in the library.

The issue is related to exceptions handling.


Please open _02_ApplicationMenuButton project and add the following code to void _buttonNew_OnExecute method.

int i = int.Parse("a");

this  code is just to demonstrate unhandled exception situation.

run the ApplicationMenuButton project  click New button and you will see that Unhanded Exception window will not shown at all.


add the same code into button1_Click event

and you will see difference.

I see big issue in it especially if we have created form object in _buttonNew_OnExecute handler then there is unhanded exception in this form then the form will be closed without any notification.


Any ideas how to solve this?


Thank you, Alex







Apr 13, 2010 at 10:56 PM

Actually there is no real problem.

What happens is that your exception is thrown as usual (you can see it on the outpane pane in Visual Studio), but if you don't handle it (by adding a try-catch block) it will start to unwind the stack.
Now, since this event handler originated from the Windows Ribbon Framework COM based library, it will silant the exception when it gets to there.
This is why the exception doesn't continue all the way up to visual studio.

But, since you can catch it normally, there is no real issue.
Anyway, I can't fix it, I can't cancel the internal "catch all" that the Window Ribbon Framework does.

Hope it helps,
Arik Poznanski.