This project has moved and is read-only. For the latest updates, please go here.

MEF inside a Silverlight Unit Test

Feb 2, 2010 at 10:14 PM

(1) I have a silverlight app, where I'm downloading a package (via the MEF PackageLoader), doing an Import via PartInitializer, and all works fine and well.

(2) I then have a Silverlight unit-test app (of the type one Jeff Wilcox created), and it has project references too all the assemblies involved.

(3) The problem is, when I call the exact same code mentioned in (1) from within the unit-test I get an error:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Within this test I can new() up an instance of the object MEF is failing to create, so it appears all required references are packaged into the unit-testing XAP.

What to do?

Is there some kind of special catalog initialization I have to do within the unit-test system?  Any advice much appreciated.



Feb 10, 2010 at 1:33 AM

I have almost the same problem with you

Mar 6, 2010 at 10:04 PM

Hey cuipengfei

Make sure you have all the references necessary in the test project.

I found that one of the project I was referencing in turn had dependencies that the TestProject did not have.  As soon as I made sure those refs were available it seemed to work.  The ErrorMessage didn't give me any hints that this might be problem though.

I'm still interested in where I can find the "LoaderExceptions property" in case I get future obscure errors being thrown.




Apr 6, 2010 at 11:36 AM

there is a good post at .

But I am having the same issue but there is no way to find out what the problem is from LoaderExceptions that I can see as the exception is ChangeRejectedException and it gives a long winded monolog that has no specifics, there must be a way to get the real issue as reflection is groping thu the Assemblies and comes up unsatisfied.