{"action":"closed","issue":{"url":"https://api.github.com/repos/seesharper/LightInject/issues/168","labels_url":"https://api.github.com/repos/seesharper/LightInject/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/seesharper/LightInject/issues/168/comments","events_url":"https://api.github.com/repos/seesharper/LightInject/issues/168/events","html_url":"https://github.com/seesharper/LightInject/issues/168","id":57317133,"number":168,"title":"Using function factory to create named instance when two named instances for interface exist","user":{"login":"bjporada","id":9321104,"avatar_url":"https://avatars.githubusercontent.com/u/9321104?v=3","gravatar_id":"","url":"https://api.github.com/users/bjporada","html_url":"https://github.com/bjporada","followers_url":"https://api.github.com/users/bjporada/followers","following_url":"https://api.github.com/users/bjporada/following{/other_user}","gists_url":"https://api.github.com/users/bjporada/gists{/gist_id}","starred_url":"https://api.github.com/users/bjporada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjporada/subscriptions","organizations_url":"https://api.github.com/users/bjporada/orgs","repos_url":"https://api.github.com/users/bjporada/repos","events_url":"https://api.github.com/users/bjporada/events{/privacy}","received_events_url":"https://api.github.com/users/bjporada/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-11T13:45:01Z","updated_at":"2015-12-15T12:42:30Z","closed_at":"2015-12-15T12:42:30Z","body":"I can work around it by creating a factory wrapper then use GetInstance directly off container.\r\n\r\npublic interface IBar { }\r\n        public class Bar1 : IBar { }\r\n        public class Bar2 : IBar { }\r\n\r\n        [TestMethod]\r\n        public void IBar_Two_NamedInstances_FuncFactory()\r\n        {\r\n            var serviceContainer = new ServiceContainer();\r\n            serviceContainer.Register<IBar, Bar1>(\"bar1\");\r\n            serviceContainer.Register<IBar, Bar2>(\"bar2\");\r\n\r\n            var factory = serviceContainer.GetInstance<Func<string, IBar>>();\r\n\r\n            //fail\r\n            var bar = factory(\"bar1\");\r\n        }\r\n\r\n        [TestMethod]\r\n        public void IBar_One_NamedInstance()\r\n        {\r\n            var serviceContainer = new ServiceContainer();\r\n            serviceContainer.Register<IBar, Bar1>(\"bar1\");\r\n\r\n            var factory = serviceContainer.GetInstance<Func<string, IBar>>();\r\n\r\n            //success\r\n            var bar = factory(\"bar1\");\r\n        }        \r\n\r\n        [TestMethod]\r\n        public void IBar_Two_NamedInstances_GetInstance()\r\n        {\r\n            var serviceContainer = new ServiceContainer();\r\n            serviceContainer.Register<IBar, Bar1>(\"bar1\");\r\n            serviceContainer.Register<IBar, Bar2>(\"bar2\");\r\n\r\n            //success\r\n            var bar = serviceContainer.GetInstance<IBar>(\"bar1\");\r\n        }"}}