First, of all thank you for the well written project and software.
I prefer to use autofac because that is what I am familiar with. Everything has worked well up unto today when I attempted to show a message box with
var result = _windowManager.ShowMessageBox("Hello");
where _windowManager is passed in through ioc.
I get the following exception:
{"The requested service 'Stylet.MessageBoxView' has not been registered. To avoid this exception, either register a component to provide the service,
check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency."}
I added the following line to AutofacBootstrapper.DefaultConfigureIoC :
builder.RegisterType();
so that DefaultConfigureIoC now looks like:
protected virtual void DefaultConfigureIoC(ContainerBuilder builder)
{
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
builder.RegisterInstance<IViewManager>(new ViewManager(viewManagerConfig));
builder.RegisterType<MessageBoxView>(); // added
builder.RegisterInstance<IWindowManagerConfig>(this).ExternallyOwned();
builder.RegisterType<WindowManager>().As<IWindowManager>().SingleInstance();
builder.RegisterType<EventAggregator>().As<IEventAggregator>().SingleInstance();
builder.RegisterType<MessageBoxViewModel>().As<IMessageBoxViewModel>().ExternallyOwned(); // Not singleton!
builder.RegisterAssemblyTypes(this.GetType().Assembly).ExternallyOwned();
}
and the message box now appears to work correctly.
First, of all thank you for the well written project and software.
I prefer to use autofac because that is what I am familiar with. Everything has worked well up unto today when I attempted to show a message box with
var result = _windowManager.ShowMessageBox("Hello");
where _windowManager is passed in through ioc.
I get the following exception: {"The requested service 'Stylet.MessageBoxView' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency."}
I added the following line to AutofacBootstrapper.DefaultConfigureIoC :
builder.RegisterType();
so that DefaultConfigureIoC now looks like:
and the message box now appears to work correctly.
Could you please confirm this is a good fix?
Lars