title: MEF can't find module's views when dll in subdirectory
body: <p>I try to make a little application with Prism and MEF in order to learn how it works. I'm stuck on a fairly frustrating problem.
  I would like to have a "Modules" subdirectory in my base app directory where I copy all the module's dll as a post build event. 
  These modules are MVVM app with View and ViewModel.</p>
  
  <p>My problem is : When I copy my module's dll in the main app directory, the views are displayed in the shell, but when my modules are in the subdirectory, nothing is displayer.
  My modules and their parts are found but according to fuslogvw the views can't be found :</p>
  
  <blockquote>
    <p><strong>* Assembly Binder Log Entry  (27/11/2015 @ 16:45:28) *</strong></p>
    
    <p>The operation failed.</p>
    
    <p>Bind result: hr = 0x80070002. The system cannot find the file specified.</p>
    
    <p>Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll</p>
    
    <p>Running under executable  C:\Users\mouarf\Downloads\Prism-Samples-Wpf-master\Prism-Samples-Wpf-master\HelloWorld\HelloWorld\bin\Debug\HelloWorld.vshost.exe</p>
    
    <p>--- A detailed error log follows. </p>
    
    <p>=== Pre-bind state information ===</p>
    
    <p>LOG: DisplayName = ModuleB.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null</p>
    
    <p>(Fully-specified)</p>
    
    <p>LOG: Appbase = file:///C:/Users/mouarf/Prism/HelloWorld/bin/Debug/</p>
    
    <p>LOG: Initial PrivatePath = NULL</p>
    
    <p>LOG: Dynamic Base = NULL</p>
    
    <p>LOG: Cache Base = NULL</p>
    
    <p>LOG: AppName = HelloWorld.vshost.exe</p>
    
    <p>Calling assembly : ModuleB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.</p>
    
    <p>===</p>
    
    <p>LOG: This bind starts in LoadFrom load context.</p>
    
    <p>WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().</p>
    
    <p>LOG: Using application configuration file: C:\Users\mouarf\Downloads\Prism-Samples-Wpf-master\Prism-Samples-Wpf-master\HelloWorld\HelloWorld\bin\Debug\HelloWorld.vshost.exe.Config</p>
    
    <p>LOG: Using host configuration file: </p>
    
    <p>LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.</p>
    
    <p>LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).</p>
    
    <p>LOG: Attempting download of new URL file:///C:/Users/mouarf/Prism/HelloWorld/bin/Debug/en-US/ModuleB.resources.DLL.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/Users/mouarf/Prism/HelloWorld/bin/Debug/en-US/ModuleB.resources/ModuleB.resources.DLL.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/Users/mouarf/Prism/HelloWorld/bin/Debug/en-US/ModuleB.resources.EXE.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/Users/mouarf/Prism/HelloWorld/bin/Debug/en-US/ModuleB.resources/ModuleB.resources.EXE.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/USERS/Mouarf/PRISM/HELLOWORLD/BIN/DEBUG/MODULES/en-US/ModuleB.resources.DLL.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/USERS/Mouarf/PRISM/HELLOWORLD/BIN/DEBUG/MODULES/en-US/ModuleB.resources/ModuleB.resources.DLL.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/USERS/Mouarf/PRISM/HELLOWORLD/BIN/DEBUG/MODULES/en-US/ModuleB.resources.EXE.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/USERS/Mouarf/PRISM/HELLOWORLD/BIN/DEBUG/MODULES/en-US/ModuleB.resources/ModuleB.resources.EXE.</p>
    
    <p>LOG: All probing URLs attempted and failed.</p>
  </blockquote>
  
  <p>I don't know why MEF look in "modules\en-US\", I think it's probably why it doesn't find any views, but I couldn't find how to specify otherwise.</p>
  
  <p>My bootstrapper : </p>
  
  <pre><code> public class Bootstrapper : MefBootstrapper
  {
      protected override void ConfigureAggregateCatalog()
      {
          base.ConfigureAggregateCatalog();
  
          this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
          string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Modules");
          DirectoryCatalog catalog = new DirectoryCatalog(path, "*.dll");
          this.AggregateCatalog.Catalogs.Add(catalog);
      }
  
      protected override DependencyObject CreateShell()
      {
          return this.Container.GetExportedValue&lt;MainWindow&gt;();
      }
  
      protected override void InitializeShell()
      {
          base.InitializeShell();
  
          Application.Current.MainWindow = (MainWindow)this.Shell;
          Application.Current.MainWindow.Show();
      }
  
      protected override void ConfigureContainer()
      {
          base.ConfigureContainer();
      }
  
      protected override IModuleCatalog CreateModuleCatalog()
      {
          return new ConfigurationModuleCatalog();
      }
  }
  </code></pre>
  
  <p>My modules :</p>
  
  <pre><code>[ModuleExport(typeof(ModuleAModule))]
  public class ModuleAModule : IModule
  {
      IRegionManager _regionManager;
  
      [ImportingConstructor]
      public ModuleAModule(IRegionManager regionManager)
      {
          _regionManager = regionManager;
      }
  
      public void Initialize()
      {
          _regionManager.RegisterViewWithRegion(RegionNames.RightRegion, typeof(ViewA));
      }
  }
  </code></pre>
  
  <p>My views :</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Interaction logic for ViewA.xaml
  /// &lt;/summary&gt;
  [Export]
  public partial class ViewA : UserControl
  {
      public ViewA()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>My viewmodels :</p>
  
  <pre><code>[Export]
  public class ViewAViewModel : BindableBase
  {
      private string _title = "Module A";
      public string Title
      {
          get { return _title; }
          set { SetProperty(ref _title, value); }
      } 
  }
  </code></pre>
  
  <p>Anyone ?</p>
  
  <p><strong>Edit :</strong> </p>
  
  <p>Here's the solution for who whould like to take a look : <a href="https://github.com/mouarf/HelloWorldPrismMef" rel="nofollow">HelloWorldPrismMef</a></p>
  
  <p><strong>Edit 2 :</strong></p>
  
  <p>The investigation still goes on, I discovered the really handy mefx ! So my problem seems to be :</p>
  
  <blockquote>
    <p>[Part] ModuleA.ModuleAModule from: DirectoryCatalog (Path="Modules")</p>
    
    <p>[Primary Rejection]</p>
    
    <p>[Export] ModuleA.ModuleAModule (ContractName="Prism.Modularity.IModule")</p>
    
    <p>[Import] ModuleA.ModuleAModule..ctor (Parameter="regionManager", ContractName="Prism.Regions.IRegionManager")</p>
    
    <p>[Exception] System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint contract name</p>
    
    <p>ContractName    Prism.Regions.IRegionManager
     RequiredTypeIdentity    Prism.Regions.IRegionManager n'a été trouvée.</p>
    
    <p>at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)</p>
    
    <p>at Microsoft.ComponentModel.Composition.Diagnostics.CompositionInfo.AnalyzeImportDefinition(ExportProvider host, IEnumerable`1 availableParts, ImportDefinition id)</p>
  </blockquote>
  
  <p>Does that mean that I need to Export a IRegionManager class ? </p>