Shell Boostrapping Error

Topics: Getting Started
Jul 10, 2012 at 9:52 PM

I am working on a CM solution based on the Billy Hollis Style Demo in the CM Hello Screens Tutorial.

Everything was working fine, but I decided to reorganize so that the contents of each folder (Customers - Orders - Settings) would reside in its own project. rather than a single project solution, as in the turotial.

I have no errors at design time but at run time I am getting the following error:

System.ComponentModel.Composition.CompositionException was unhandled by user code
  Message=The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Single stepping in the bootstrapper, I can see  in Configure (container.Compose(Batch) that all of the ViewModels from each of the projects are listed in the container, proving that my code in the bootstrappers Select Assemblies and Configure seem to be working OK.

Since the only changes I made to code which was previously working OK, was the minimum changes needed to operate in seperate contents of folders into  projects, the cause must be simple.  Yet I cant seem to find it.

I'm not sure if this is a MEF or a CM issue.  Could anyone suggest where to look?  Traditional debugging methods just dont provide access to the cause for this error.


Jul 11, 2012 at 6:28 AM
Edited Jul 11, 2012 at 6:29 AM

that type of error is more than likely related to MEF, since the CompositionException occurred is the only clue.

Jul 12, 2012 at 3:06 AM

Thanks for pointing me in the right direction.  It does appear to be a MEF issue, but still very hard to find.

I located this excellent site about MEF debugging :

I have still not solved the issue, but I thought other readers may appreciate the link for insight about MEF errors -  MEF is absolutely fantastic, (but a bit of a bugger if you have to chase down a failure). I will listen to any ideas . . . .



Jul 15, 2012 at 4:47 PM
Edited Jul 15, 2012 at 4:50 PM

When I first began to learn WPF, I was sometimes overwhelmed with the number of errors that the designer reported in Visual Studio from a single mistake.   But, I have learned to take this in stride and while I wish for better debuggin aids for WPF, I have learned how to work with what is available.

It appears that MEF has some of the similar debugging problems to WPF.  In short, we must learn to take the reported errors with a "grain of salt" and not regard then as literal errors.  The error first reported above was finally found - - - turned out to be a typo in a Namespace.  Unfortunately, the error text only seems to make sense after the error was found, using independent means of discovery.