我正在開發一個用戶控件並在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