{"action":"created","issue":{"url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/22","repository_url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter","labels_url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/22/comments","events_url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/22/events","html_url":"https://github.com/volosoft/castle-windsor-ms-adapter/issues/22","id":276201178,"number":22,"title":"Wrong constructor called","user":{"login":"mbp","id":77322,"avatar_url":"https://avatars0.githubusercontent.com/u/77322?v=4","gravatar_id":"","url":"https://api.github.com/users/mbp","html_url":"https://github.com/mbp","followers_url":"https://api.github.com/users/mbp/followers","following_url":"https://api.github.com/users/mbp/following{/other_user}","gists_url":"https://api.github.com/users/mbp/gists{/gist_id}","starred_url":"https://api.github.com/users/mbp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbp/subscriptions","organizations_url":"https://api.github.com/users/mbp/orgs","repos_url":"https://api.github.com/users/mbp/repos","events_url":"https://api.github.com/users/mbp/events{/privacy}","received_events_url":"https://api.github.com/users/mbp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-22T20:53:16Z","updated_at":"2017-11-23T05:35:45Z","closed_at":null,"author_association":"NONE","body":"Consider the following code\r\n\r\n```\r\npublic interface IMyService\r\n{\r\n}\r\n\r\npublic class MyService : IMyService\r\n{\r\n    public MyService()\r\n    {\r\n        Console.WriteLine(\"Default constructor called!\");\r\n    }\r\n\r\n    public MyService(params string[] foo)\r\n    {\r\n        Console.WriteLine(\"Custom constructor called!\");\r\n    }\r\n}\r\n```\r\n\r\nI register it as follows:\r\n\r\n```\r\ncontainer.Register(Component.For<IMyService>().ImplementedBy<MyService>());\r\n```\r\n\r\nWhen I call `container.Resolve<IMyService>()` from a normal console application not involving castle-windsor-ms-adapter, the default constructor is called.\r\n\r\nWhen I call `container.Resolve<IMyService>()` from an ASP. NET Core project using this library (`return WindsorRegistrationHelper.CreateServiceProvider(container, services);` in `Startup.cs`, the second constructor is called.\r\n\r\nI would have expected the default constructor always be called, as by out-of-the-box Castle Windsor behaviour. Am I missing anything?"},"comment":{"url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/comments/346535056","html_url":"https://github.com/volosoft/castle-windsor-ms-adapter/issues/22#issuecomment-346535056","issue_url":"https://api.github.com/repos/volosoft/castle-windsor-ms-adapter/issues/22","id":346535056,"user":{"login":"hikalkan","id":1210527,"avatar_url":"https://avatars1.githubusercontent.com/u/1210527?v=4","gravatar_id":"","url":"https://api.github.com/users/hikalkan","html_url":"https://github.com/hikalkan","followers_url":"https://api.github.com/users/hikalkan/followers","following_url":"https://api.github.com/users/hikalkan/following{/other_user}","gists_url":"https://api.github.com/users/hikalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalkan/subscriptions","organizations_url":"https://api.github.com/users/hikalkan/orgs","repos_url":"https://api.github.com/users/hikalkan/repos","events_url":"https://api.github.com/users/hikalkan/events{/privacy}","received_events_url":"https://api.github.com/users/hikalkan/received_events","type":"User","site_admin":false},"created_at":"2017-11-23T05:35:45Z","updated_at":"2017-11-23T05:35:45Z","author_association":"OWNER","body":"This library does nothing about the constructor selection. So, I could not understand why there is a difference here.\r\n\r\nHowever, I believe the constructor design of this sample is very tricky and badly designed in general. You should remove the first constructor. In addition, if you use dependency injection, it will be a problem to pass string[] to the second ctor. So, I think this is not a good and realistic sample to spend time to find the problem :)"}}
{"actor":{"display_login":"hikalkan"}}