Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: Bootstrapper with Unity Yields Exception

$
0
0
Greetings

I am using Unity as my IOC container in the bootstrapper. In version 1.3.1, the below simplified bootstrapper runs fine. However, in versions 1.4 and 1.4.1, the below bootstrapper throws a ResolutionFailedException on the following line saying that the unity container can not resolve an object of type Caliburn.Micro.IWindowManager:
var result = _container.Resolve(serviceType, key);
Can someone please verify whether this is a bug in 1.4/1.4.1 or if it was a fix in 1.4/1.4.1 that is now causing desired behavior. Thank you.

        protected override void Configure()
        {
            _container = new UnityContainer();
            _container.RegisterType<IShellViewModel, ShellViewModel>();
        }

        protected override object GetInstance(Type serviceType, string key)
        {
            var result = _container.Resolve(serviceType, key);

            if (result == null)
                throw new Exception(string.Format("Could not locate any instance of contract {0}", serviceType.ToString()));

            return result;
        }

        protected override IEnumerable<object> GetAllInstances(Type service)
        {
            return _container.ResolveAll(service);
        }

        protected override void BuildUp(object instance)
        {
            _container.BuildUp(instance);
        }

        protected override IEnumerable<System.Reflection.Assembly> SelectAssemblies()
        {
            return new[] {
                Assembly.GetExecutingAssembly()
            };
        }
    }

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>