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?
You might be running into this problem:
@"C:\Program Files\MyCompany\MyApp\Bin"might not be in the probing path. I can’t say I have experienced the issue or explored it much. See Daniel Plaisted’s Blog for details, scroll down to the section ‘Assembly Load Issues’How to Debug and Diagnose MEF Failures