I am developing a user control and use it inside an ElementHost. I define the resource dictionary as follows:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Classic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
In my VS explorer, I have this
Project (the user control library)
|_ Themes
|__ Generic.xaml (Build Action = Page)
|__ Classic.xaml (Build Action = Page)
There's no compilation error and the VS designer seems to pick up the resources defined in Classic.xaml
However, it crashes at runtime with the following exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Windows.Markup.XamlParseException: 'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '16' and line position '18'. ---> System.IO.IOException: Cannot locate resource 'themes/classic.xaml'.
What's going on?