silverlight-5.0resourcedictionarypack-uri

Merging a resource from another Assembly in Silverlight


I added a Resource Dictionary named ResourceDictionary1 to my silverlight project.

I also added a Silverlight Class Library to my project named OtherAssembly, then in this new assembly I added a new Resource Dictionary named ResourceDictionary2:

Project Structure

In my original project I'm trying to merge both dictionaries in MainPage.xaml:

  <ResourceDictionary>
     <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="MyResourceDictionary1.xaml" />
        <ResourceDictionary Source="/OtherAssembly;component/MyResourceDictionary2.xaml" />
     </ResourceDictionary.MergedDictionaries>

When I run the project the line with OtherAssembly throws an exception, saying that there's an error assigning the property System.Windows.ResourceDictionary.Source in that line:

Error

But at design time, the designer shows everything in order, it finds all the resources.

I don't know, It seems that the Pack Uri syntax is not well formed.

Anybody knows why I get this error message?


Solution

  • I found the answer.

    I needed to add a reference to OtherAssembly, as the error is not detected until run time, it's hard to detect it.