Since that’s the third time I’ve been asked about it, and in fact came across the problem myself, I thought I should blog my reply to help future users.
You use the Windows Ribbon Framework, either directly (in C++) or in managed code using my Windows Ribbon for WinForms library. You add a close button to the ribbon which closes the application. The application crashes on close.
Don’t Cut the Branch You Sit On
The problem is that you try to call
ribbon.DestroyFramework, which ultimately calls
IUIFramework.Destroy from a ribbon command handler. So while handling the ribbon event, you try to kill the ribbon. It is only fair that the ribbon control fights back.
Either invoke the
Close() method asynchronously:
or don’t call
DestroyFramework when closing the application (and trust windows for releasing the resources).
[By the way, the C++ solution is simply to call
PostMessage(WM_CLOSE) instead of
I’ve updated sample 04-TabGroupHelp on the project site so that it has a real exit button on the ribbon that closes the form.
That’s it for now,