Getting Caliburn.Micro to bind my view and virtual machine in a separate assembly using Windsor

I am using Caliburn.Micro bootstrapper here:

https://gist.github.com/1127914

Everything works if I save all views and view modes in the same project as bootstratpper.

But I wanted to click the Views and ViewModels folder on another assembly / project, I do, change namespaces, update the bootloader to find this viewmodel model. Now when I run, I get an error

"No component to support the MVVMBook.ViewModules.ViewModels.MainViewModel service was found."

in this part of the bootloader:

return string.IsNullOrWhiteSpace(key)
               ? _container.Resolve(service)
               : _container.Resolve(key, service);

Obviously, it cannot mount the ViewModel, although the VM is set as a general parameter in Bootstrapper:

 public class CastleBootstrapper : Bootstrapper<MainViewModel>

, , "" "" "ViewModels", - MainView.xaml MainViewModel.cs

, ?

, , view viewmodels , :

// needed if views and viewmodels are in a seperate assembly
  protected override IEnumerable<Assembly> SelectAssemblies()
  {
     return new[]
               {
                  Assembly.GetExecutingAssembly()
               };
  }
+3
1

ViewModel , . ApplicationContainer, , RegisterViewModels, :

private void RegisterViewModels()
{
    Register(AllTypes.FromAssembly(GetType().Assembly)
                    .Where(x => x.Name.EndsWith("ViewModel"))
                    .Configure(x => x.LifeStyle.Is(LifestyleType.Transient)));
}

ViewModels , ApplicationContainer.

, , . , RegisterViewModels CastleBootstrapper Configure() :

protected override void Configure()
{
     _container = new ApplicationContainer();
     _container.AddFacility<TypedFactoryFacility>();
     _container.Register(AllTypes.FromAssembly(typeof(MainViewModel).Assembly)
         .Where(x => x.Name.EndsWith("ViewModel") || x.Name.EndsWith("View"))
         .Configure(x => x.LifeStyle.Is(LifestyleType.Transient)));
}

- . Caliburn , SelectAssemblies():

protected override IEnumerable<Assembly> SelectAssemblies()
{
   return new[]
   {
       Assembly.GetExecutingAssembly(),
       typeof(MainViewModel).Assembly
   };
}

Castle.Windsor http://stw.castleproject.org/Windsor.MainPage.ashx

+6

All Articles