Set up application resources from code
I think you need to specified the name of the component were the resource is sitting in
<ResourceDictionary Source="/<YourDllName>;component/Resources/Styles/Shared.xaml" />
If your dll is named My.Wpf.Component.dll you should put My.Wpf.Component
so in code it should be
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/<YourDllName>;component/Resources/Styles/Shared.xaml", UriKind.Relative) });
This code works for me. I just changed the URIs to relative:
ResourceDictionary myResourceDictionary = new ResourceDictionary();
myResourceDictionary.Source = new Uri("Dictionary1.xaml", UriKind.Relative);
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("Dictionary2.xaml", UriKind.Relative);
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);