0
votes

I wanted to use Windsor castle as IoC and prism for mvvm in my ui.

So I register all my classes with the windsor bootstrapper:

            Container.Register(
            Classes.FromThisAssembly()
                .Pick()
                .WithServiceAllInterfaces()
                .WithServiceSelf()
                .WithServiceBase()
                .LifestyleTransient());

Then i want to navigate to my View:

RegionManager.RequestNavigate(RegionNames.SideBarRegion, "PreEventNavigationView");

Then an exception is thrown. The important information from the stacktrace are:

{"Activation error occurred while trying to get instance of type Object, key \"PreEventNavigationView\""}

And

{"Requested component named 'PreEventNavigationView' was not found in the container. Did you forget to register it?\r\nThere are 55 other components supporting requested service 'System.Object'. Were you looking for any of them?"}

I assumed that I need to register my components for system.object but that didn't help either. With this my UI doesn't work and i get some weired behaviour:

        Container.Register(
            Component.For<PreEventNavigationView,System.Object>()
                .ImplementedBy<PreEventNavigationView>().LifestyleSingleton());

I think i read somewhere that i should NOT register object with windsor castle. How can I use the Prism Navigation correctly with windsor castle or is it not possible?

1

1 Answers

0
votes

Problem was this part:

        Container.Register(
        Classes.FromThisAssembly()
            .Pick()
            .WithServiceAllInterfaces()
            .WithServiceSelf()
            .WithServiceBase()
            .LifestyleTransient());

I only registered them with the Full Namespace (Or windsor does by default), not only the class name. So there are 2 soultions:

RegionManager.RequestNavigate(RegionNames.SideBarRegion, "Full.NameSpace.PreEventNavigationView");

or

        Container.Register(
        Classes.FromThisAssembly()
            .Pick()
            .Configure(registration => registration.Named(registration.Implementation.Name))
            .WithServiceAllInterfaces()
            .WithServiceSelf()
            .WithServiceBase()
            .LifestyleTransient());