There’s a bug in Silverlight 4 that prevents you from being able to use resources that are declared in a ResourceDictionary in a referenced assembly. The error is a XamlParseException whose message is “Failed to assign to property ‘System.Windows.ResourceDictionary.Source’.”. The problem is that if you have a Silverlight class library whose name ends with “.Resources” it blows up at runtime. To fix the problem, you must change the assembly name (in the project properties) so that it does not end with “.Resources” but, perhaps, ends with “.Resources.YouHaveToBeKiddingMe“.
Here is an example of using a resource dictionary in an external assembly that will blow up at runtime:
Here is a fixed version:
If you compile a Silverlight application against a project whose assembly’s name ends with “.Resources” that DLL won’t even get included in the XAP or listed in the AppManifest.xml file. It simply gets ignored, which lead to hours of head-bashing debugging for me. I hope this workaround saves others the grief!