开发者

Avoid exceptions from module in the application

I'm developing an application that contains a module that other team develop and I'm hosting it using MEF. the problem is that when the hosted module has an exception it collapse my application.

the obvious solution is that the d开发者_Python百科evelop team of the hosted module will catch all their exceptions but it's not happening so I have to ensure myself.

My ideas:

1) create 2 separated GUI threads. is it possible ?

2) run the hosted module as separated .exe file but host it somehow in my application.

Any help will be appreciated.

Avoid exceptions from module in the application


Well first you should implement the Application.DispatcherUnhandledException event, for further details click here.

After doing this you should talk to the other team to improve the robustness of their module.

EDIT:

Or you could follow this approach. But I would try to improve the robustness.


I think the best approach is to set up some tests to verify that the modules you use from the other team work for your purposes.

Apart from that obvious, but time consuming approach, you could attach an event handler to the Application.DispatcherUnhandledException and gracefully handle exceptions from your imported module. You should be able to find the source of the exception in the event args' Exception.Source property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜