Loading ResourceDictionary at Run Time from Assemblies of the Same Name

I ran into some problem when trying to load resources from two separate assemblies with the same name but located in a different folder :

  • C: \ folder1 \ fcl.dll
  • C: \ folder2 \ fcl.dll

A ResourceDictionarynamed Resources.xaml is embedded (like a page) in each of these assemblies.

To download the first ResourceDictionary, I use the following snippet:

// Load the assembly in memory
var assembly = Assembly.LoadFrom(@"c:\folder1\FCL.Dll");

// Get Dictionnary 
var uri = string.Format("pack://application:,,,/{0};Component/Resources.xaml", assembly.GetName().Name);
var resourceDictionary = new ResourceDictionary { Source = new Uri(uri) };

It works!

But when I try to load the second ResourceDictionarywith the same code fragment (just changing Assembly.LoadFrom(@"c:\folder1\FCL.Dll")to Assembly.LoadFrom(@"c:\folder2\FCL.Dll"), it does not load resources from c: \ folder2 \ fcl.dll, but those that are stored in the previously loaded directory c: \ folder1 \ fcl.dll: - (

: shortAssemblyName URI , FCL:

 var uri = string.Format("pack://application:,,,/{0};Component/Resources.xaml", assembly.GetName().Name)

- , ?

+5
1

, , Assembly.LoadFrom . , .

0

All Articles