Enterprise Library Exception Handling for Prism class library

Topics: Prism v4 - WPF 4
Aug 29, 2011 at 3:20 PM


I'm trying to use Enterprise Library 5 Exception Handling in my Prism class library application (using MEF). Since I can't put the exceptionHandling configuration in App.config (like StockTraderRI ), I probably need to use code to load the

exception config file in bootstraper.

1. How should I do this?

2. Do I need to use Fluent interface? Can I use Fluent if this is MEFBootstrapper?



Aug 29, 2011 at 7:00 PM

Hi Julie,

As far as I know there is no official support for Enterprise Library in Prism, however, you might a better support about how to load the exception config file (and thus, apply this approach in your application) in the Enterprise Library forums:


Damian Cherubini

Aug 29, 2011 at 7:59 PM

Hi Damian,

So for Prism to use my exception handler, should I define a class "MyHandler" (like "EnterpriseLibraryLoggerAdapter" in StockTraderRI), but implement IMyHandler interface. And put the load config file part (which hopefully I can find in the other forum) in the constructor of this class (or some inilize mothod). Then use:

Then, MyHandler can be injected into the constructor of all the mocules that need to handle exceptions.
Is this the right approch?
Aug 30, 2011 at 2:24 PM


The approach you're following seems to be a valid possiblity to achieve your scenario. You should note that you could also use the declarative Export attribute to define the interface mapping between the IMyHandler interface and the MyHandler implementation.

You can read more about the Export attribute in the this section from the Mef Programming Guide.

I hope you find this helpful.

Guido Leandro Maliandi 

Oct 12, 2011 at 2:30 PM

Hi Guido,

I have MyHandler which implement IMyHandler and has a [Export] attrubute. Now I can import it in ever of my module. But I noticed that sometime if a view has problem, I can see the exception thrown in InteliTrace but in my Prism app it just continues and won't display the view. 

In order to catch every exception, do I have to put try, catch block in every function in every module? Is there a "out most" place that I can put a try catch?


Oct 12, 2011 at 8:31 PM

Hi Julie,

Based on my understanding of your scenario, this could be happening because Prism's navigation service raises the NavigationFailed event when an exception appears instead of throwing the exception.

If this is the case you might find the following blog post useful:

Please let us know if we misunderstood your scenario.

I hope you find it useful,

Damian Cherubini