Home Ask Login Register

Developers Planet

Your answer is one click away!

Neil February 2016

WPF MVVM load View and ViewModel from external assembly

so I have inherited the development of a WPF application that uses Caliburn.Micro. I have been tasked to extend the application and include some AddIn functionality, I have coded the core logic for the AddIn feature which all works pretty well until I run the application and the shell view informs me that it "Cannot find view for TestViewModel"

Here is my Configure method in the bootstrapper

protected override void Configure()
                (Action)(() => SplashScreenForm.SplashScreen.Message = "Initializing Container..."));

        this._container = new CompositionContainer(new AggregateCatalog(new DirectoryCatalog(".", "*")));
        var batch = new CompositionBatch();

                (Action)(() => SplashScreenForm.SplashScreen.Message = "Initializing Dependencies..."));
        batch.AddExportedValue<IWindowManager>(new WindowManager());
        batch.AddExportedValue<IEventAggregator>(new EventAggregator());

    catch (Exception ex)
        this._log.ErrorFormat("-->AppBootstrapper.Configure - {0}\n{1}", ex.Message, ex);
        throw new Exception(ex.Message, ex);


I then have two assemblies, AppMain which contains the main application logic (this has a ViewModels and Views folders and these all load fine), I also have an AppAddinTest assembly which contains a test addin, this also contains a ViewModels and Views folder.

My TestViewModel code is:

public class TestViewModel : BaseViewModel, ITestViewModel
    private readonly IEventAggregator _eventAggregator;



EngineerSpock February 2016

I bet you haven't added the assembly on the stage of bootstrapping where your ViewModel resides. Override SelectAssemblies() in the bootstrapper:

protected override IEnumerable<Assembly> SelectAssemblies() {
        var assemblies = new List<Assembly> {
        return assemblies;

Post Status

Asked in February 2016
Viewed 2,471 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life