Cannot find view (with SelectAssemblies&NameTransformer.AddRule...)

Topics: Bootstrappers & IoC
Sep 4, 2013 at 5:21 PM
Edited Sep 5, 2013 at 9:26 AM
[SOLVED]

I have 3 Assemblies, the exe with the Bootstrapper, one dll with the "ShellView" and one with the "ShellViewModel"

xxx.Ui.Wpf.Starter (exe)
xxx.Ui.Wpf.Shell (dll; Views are in the Views-Subdirectory/Namespace)
xxx.Pl.Wpf.Shell (dll; ViewModels are in the ViewModels-Subdirectory/Namespace)

I add Rules to the NameTransformer In the Bootstrapper:
ViewModelLocator.NameTransformer.AddRule(
    @"^xxx\.Ui\.Wpf\.(?<bereich>[A-Za-z_]\w*)\.Views\.(?<basisname>[A-Za-z_]\w*)View$",
    @"xxx.Pl.Wpf.${bereich}.ViewModels.${basisname}ViewModel");
ViewLocator.NameTransformer.AddRule( // <-- My mistake (ViewLocator not ViewModelLocator)
    @"^xxx\.Pl\.Wpf\.(?<bereich>[A-Za-z_]\w*)\.ViewModels\.(?<basisname>[A-Za-z_]\w*)ViewModel$",
    @"xxx.Ui.Wpf.${bereich}.Views.${basisname}View");
I test the ViewModelLocator.TransformName-Method with the ViewModel-Name and get the right View-Name ("xxx.Pl.Wpf.Shell.ViewModels.ShellViewModel" => "xxx.Ui.Wpf.Shell.View.ShellView").

I also override the SelectAssemblies-Method:
protected override IEnumerable<Assembly> SelectAssemblies()
{
    var assemblies = new List<Assembly>();
    assemblies.AddRange(base.SelectAssemblies());
    assemblies.AddRange(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory)
        .Where(file => file.EndsWith(".dll") && file.Contains("xxx.Ui.Wpf."))
        .Select(file => Assembly.Load(AssemblyName.GetAssemblyName(file))));
    return assemblies;
}
After starting the Application i get a Window with the Message "Cannot find view for xxx.Pl.Wpf.Shell.ViewModels.ShellViewModel". I use Castle Windsor as IOC-Container, an both Types are registered.