我已经创建一个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项目不会将其复制到其输出目录。如果我自己手动复制文件,一切都很好。 –