I'm running into an odd problem with MEF's composition container and directory catalog where I pass in a full path to a folder containing assemblies:
In C:\Program Files\MyCompany\MyApp\Bin
AssemblyA: ExportedTypeA, ExportedTypeB
AssemblyB: BaseExportedTypeA, BaseExportedTypeB
Executed from another location (C:\users\Me\dev\project\foo\bar\bar2\bin\debug\OtherApp.Exe)
In the application I call:
string ProviderPhysicalPath = @"C:\Program Files\MyCompany\MyApp\Bin";
using (DirectoryCatalog catalog = new DirectoryCatalog(ProviderPhysicalPath))
using (CompositionContainer container = new CompositionContainer(catalog))
{
container.ComposeParts(this);
}
On container.ComposeParts(this)
I get the following exception:
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Could not find a part of the path 'C:\USERS\Me\dev\project\foo\bar\bar2\BIN\DEBUG\BIN\'.
What's confusing is two parts:
- Why is it looking in a directory I haven't specified?
- And why is it appending \bin\ to the executing directory to do it?
Is there something I'm doing wrong?