title: Referencing Resource Dictionaries in a separate project
body: <p>I've recently split my silverlight application into several smaller projects.</p>
  
  <p>I've moved all of the resource dictionaries containing my styles into a separate project ("Application.Themes") I then reference these from my App.xaml file within my main project.</p>
  
  <p>This works fine for the main project however all other projects that reference styles within these resource dictionaries throw "Object Reference not set to an instance of an object" exceptions within the designer, although they do compile and run without any problems and with the correct styles.</p>
  
  <p>I've added an App.xaml file to each of the individual projects which references the same dictionaries as my main App.xaml file, this has made no difference.</p>
  
  <p>Is there a correct way to reference resource dictionaries from another project which allows the designer to be used?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is some more information and some code snippets to demonstrate the issue I'm having</p>
  
  <p>I have a styles project called "Themes" within this project I have several dictionaries that define all of the styles for the project.</p>
  
  <p>Within my main App.xaml I have the following</p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="/Themes;component/Styles/CoreStyles.xaml"/&gt;
              &lt;ResourceDictionary Source="/Themes;component/Styles/Styles.xaml" /&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
  </code></pre>
  
  <p>If I reference styles within the main project they work correctly. however they don't for any other projects even if those projects reference the Themes project.</p>
  
  <p>I've attempted to put the following at the start of each UserControl in order to resolve the styles at design time, however it still cannot resolve styles that are within the project.</p>
  
  <pre><code>&lt;UserControl&gt;
      &lt;UserControl.Resources&gt;
          &lt;ResourceDictionary&gt;
              &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="/Themes;component/Styles/CoreStyles.xaml"/&gt;
                  &lt;ResourceDictionary Source="/Themes;component/Styles/Styles.xaml" /&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
  
      &lt;!-- Additional Control Specific resources --&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/UserControl.Resources&gt;
  
  
  &lt;!-- The following resources are defined in Styles.XAML and don't resolve at design time  and throw errors --&gt;
  &lt;TextBlock Text="Header Test"
             FontFamily="{StaticResource HeaderFontFamily}"
             Foreground="{StaticResource StrongBrush}"&gt;
  
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>My styles.xaml looks similar to this.</p>
  
  <pre><code>&lt;ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
      xmlns:behaviors="clr-namespace:Minerva.Presentation.Behavior;assembly=Minerva.Presentation"
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"&gt;
  
  &lt;SolidColorBrush x:Key="StrongBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.StrongColor}" /&gt;
  &lt;FontFamily x:Key="HeaderFontFamily"&gt;Segoe UI Light, Lucida Sans Unicode, Verdana&lt;/FontFamily&gt;
  
  &lt;/ResourceDictionary&gt;
  </code></pre>