I need to load my ResourceDictionary from some assemblies at runtime.
First i set BuildAction of the ResourceDictionary with Page, and use the code to build the uri.
var uri = new Uri(string.Format(@"/{0};component\Resources\MyResource.xaml",
assemblyName), UriKind.RelativeOrAbsolute);
That works, but then i realized that, i need to check the assembly, before i set the uri to my ResourceDictionary. Because, if the ResourceDictionary is not in the assembly, that will throw a exception.
var rd = new ResourceDictionary
{
Source = uri
};
So i set the BuildAction of my ResourceDictionary with EmbeddedResource, in order to see the ResourceDictionary in the assembly with the code below:
var hasResource = assembly.GetManifestResourceNames().
Any(resourceName => resourceName.EndsWith("MyResource.xaml"));
But now, i can't load the ResourceDictionary with the uri. I have tried all i can, but no success.
Any idea? Thanks!