我正在开发一个用户控件并在ElementHost中使用它。我定义了资源字典如下:在运行时无法找到资源字典文件
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Classic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
在我的VS探险家,我有这个
Project (the user control library)
|_ Themes
|__ Generic.xaml (Build Action = Page)
|__ Classic.xaml (Build Action = Page)
有没有编译错误和VS设计师似乎拿起Classic.xaml
定义的资源然而,它崩溃在运行时有以下例外:
System.Reflection.TargetInvocationException:异常已被抛出通过的目标调用。 ---> System.Reflection.TargetInvocationException:调用的目标引发了异常。 ---> System.Reflection.TargetInvocationException:调用的目标引发了异常。 ---> System.Windows.Markup.XamlParseException:'Set property'System.Windows.ResourceDictionary.Source'抛出一个异常。'行号“16”和行位置“18”。 ---> System.IO.IOException:找不到资源'themes/classic.xaml'。
这是怎么回事?
注意,按照http://stackoverflow.com/questions/17083370/why- do-modify-project-output-directories-cause-ioexception-was-unhandled的输出路径也是一个问题。 – nietras 2013-11-11 16:53:40