我已經創建一個WPF擴展到現有的Win32 MFC客戶端應用程序。在位於我的WPF類庫一個用戶控件,我合併庫如下:WPF資源訪問從不同的程序集,如果沒有App.xaml
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyResourceDLL;Component/dictionaries/styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
我也試過
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyResourceDLL;Component/dictionaries/styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
在任何情況下,我得到以下XamlParseException:
System.Windows.Markup.XamlParseException occurred
Message =「MyResourceDLL; Component/dictionaries/styles.xaml' valu e不能被分配給屬性 對象'Source' 'System.Windows.ResourceDictionary'。 找不到資源 'ems.wpf.resources; component/dictionaries/styles.xaml'。 錯誤在 標記文件對象 「System.Windows.ResourceDictionary」 「SARMaster.Maryln.EphemerisLib;組件/ getephemeriscontrol.xaml」 線9的位置37」
我沒有一種方法可以加載一個沒有被主項目引用的相對DLL?
不明白。爲什麼不引用包含資源字典的程序集?我想,你需要進一步解釋你的情況。 –
您是否試過[this](http://stackoverflow.com/questions/709087/load-a-resourcedictionary-from-an-assembly)? – dowhilefor
Kent,WPF類庫引用包含資源字典的程序集。我需要告訴宿主MFC應用程序將所有託管DLL複製到其輸出目錄或其他東西。不像WPF主機,將此程序集引用添加到MFC項目不會將其複製到其輸出目錄。如果我自己手動複製文件,一切都很好。 –