Debugging Composition Errors?

Topics: Prism v4 - WPF 4
Jul 31, 2012 at 10:19 PM

I've so far not found anything useful to debug composition errors.  Is there anything available or recommended yet?

We deal with this occasionally where something deep in the composition chain fails on app startup.  The error messages we get are usually useless as they only report something at the top level of the chain (ie. Unable to compose Shell) when we know the problem is some other module.

Ideally I'd like to have the ability to see/log what happens with each module during all of the bootstrapper steps:  create/configure catalog, initialize modules, compose shell etc.

Any suggestions or tools out there?


Aug 1, 2012 at 2:46 PM


I believe, you could benefit from the use of the ILoggerFacade interface provided by Prism, which is used by some components of the Prism library to log information, warning messages, or error messages. This way, for example you should be able to track the logged stages of the bootstrapping sequence as each stage is logged using this interface.

The default implementation of this interface provided by Prism (TextLogger) writes each log entry to the console output, but you could provide you custom logger implementation by overriding the CreateLogger method of your bootstrapper.

For more information about changing the logging implementation:

Also, if you need to track when a module loads or fails to load you could use the LoadModuleCompleted event provided by the ModuleManager service. More information about this, can be found in the following section of the Prism documentation:

Additionally, for an example that uses both of this approaches you could check the Modularity QuickStarts, which displays the log entries from the bootstrapping sequence and module-loading details.

I hope you find this useful,

Agustin Adami

Aug 2, 2012 at 4:59 PM


We use the ILoggerFacade pattern extensively.  There are no opportunities to log when composing a part that I've seen.  Composition either succeeds or fails.

We currently don't use the IModuleManager since we don't load any modules on demand.

I'm trying to find ways to more efficiently debug problems when CreateShell fails due to composition.  In this case, the Export of the Shell fails due to a composition error deep in the chain, for example:

ShellView->ShellViewModel->SomeOtherExport->SomeOtherExport->SomeOtherExport->FailedExport   <--- The error message does not identify which export failed, it will always say the Shell composition failed.

Are there any other inspection or diagnostic tools?

Aug 2, 2012 at 6:56 PM


As far as I know, Prism does not provide any specific method or tools for debugging composition errors when composing parts in a container. Based on my understanding, this is because Prism follows the approach of being agnostic to the container used in the application. What is more, different containers can work in different ways and might need to be "debugged" with different methods.

Based on your comments, it seems you are using MEF. If that is the case, there are several available methods and tools to debug composition errors. As a starting point, you could check the following articles, which I believe could be useful to find the cause behind the errors you are experiencing:

I hope you find this useful,

Damian Cherubini

Aug 2, 2012 at 8:51 PM

Ah of course.  I keep forgetting where the boundaries are between Prism and MEF.

Thanks for pointing me in the right direction.