Enable MEF Debugging

Mar 12, 2012 at 5:11 AM

Is there anyway I can use the MEFDebug class to debug my Jounce application?

How do i turn this on? I've read your blog on debugging MEF but there's not instruction to enable it there.

Mar 12, 2012 at 1:30 PM

The MEF Debugger writes to whatever logger is attached. The default logger use the Debug window to write out information. All you have to do is set the severity level. When you "mount" Jounce to your application in the App.xaml, you can set the debug severity as a parameter on the Application service. Set it to verbose to see the MEF Debugger messages.

Mar 12, 2012 at 10:40 PM

I have my application set to 

        <Services:ApplicationService IgnoreUnhandledExceptions="False" LogSeverityLevel="Verbose"/>

but it doesn't seems to spit out the information. Do I need to set the logger too?

Mar 22, 2012 at 2:20 PM

I believe there's another post around here where Jeremy explains that if you're using the release version of Jounce (e.g. from NuGet) you won't see any output because the default logger uses Debug.WriteLine and but Debug.WriteLine is marked with a Conditional attribute so it doesn't execute in a release assembly.

I was struggling with the same thing until I found that explanation, which made perfect sense.    At that point I just pulled in the source for the Jounce DefaultLogger and marked it with [Export(typeof(ILogger))] and all was good :-)

Mar 22, 2012 at 10:49 PM

Thanks jandersen78. Just the thing I've been looking for.

Mar 26, 2012 at 9:43 PM

Also all you have to do is implement your own logger and export it, and you will get the debug back because Jounce will route debug to yours (compiled with debug flag set) rather than the internal one (compiled without it).