This project has moved and is read-only. For the latest updates, please go here.

DirectoryCatalog issue. Loads the assembly from Current folder instead.

Feb 28, 2013 at 3:47 AM
Hi All,

I have a scenario where my application (say Program.exe) runs from a Bin folder. There is a Bin/Plugins folder which has some more assemblies (say Plugin1.dll and Plugin2.dll). For some reasons I also have a Plugin1.dll in the Bin folder. (So Plugin1.dll exists in Bin and in Plugins folder). Both DLLs have a little different implementation (another story!)

Next I am creating a DirectoryCatalog for Plugins Folder, and in the output log I see that as soon as I create a DirectoryCatalog for Plugins folder, MEF seems to load the Plugin1.dll from Bin folder, where as I expected it to load the Plugin1.dll from Bin/Plugins folder, as that is where the DirectoryCatalog points to.

I think that even though internal code in DirectoryCatalog intends to load Bin/Plugin/Plugin1.dll, but when it actually loads the dll, it just loads it from the current folder where Program.exe is being run from.

As a different test, I removed the Bin/Plugins/Plugin1.dll and kept the Plugin1.dll in Bin, then it does NOT even look for Plugin1.dll, so it confirms that while creating the DirectoryCatalog object, it certainly looks at Bin/Plugin folder (which is correct) but when it comes to load, it loads Plugin1.dll from the current folder, instead of the folder passed to DirectoryCatalog.

Can anyone confirm that this is not the correct behavior, or if it is, then why?