0
votes

I load assemblies at runtime from different folders. I then instantiate all types which contain a specific interface typeof(I).IsAssignableFrom(xy)

However, if the assembly containing the interface gets loaded by mistake (because someone placed it in one of the folders), no types will get loaded. I assume because of the mismatch with the interface type. I don't really understand why, since the .dlls are identical.

Also, is there a good way to fix this problem (I can“t get the strong name without Assembly.LoadFrom)

Additional Information: as an example: program.exe has a dll dependency interfacedefinition.dll

in a Subfolder of this program is a dll called "loading.dll".

if the interfacedefinition.dll exists in both, the main folder containing program.exe AND the Subfolder containing the loading.dll i get the described problem

1
You would have to use Load() instead of LoadFrom() or put the interface assembly in the GAC. - Hans Passant

1 Answers

0
votes

You should then prevent reloading the containing assembly by keeping a List<string> for example to hold a list of assembly names that should not be loaded. Check if the assembly you are about to load is contained in that List.