{"action":"created","issue":{"url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/6","labels_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/6/comments","events_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/6/events","html_url":"https://github.com/structuremap/structuremap.dnx/issues/6","id":124551546,"number":6,"title":"Setter Injection does not work in controllers","user":{"login":"rguerreiro","id":545325,"avatar_url":"https://avatars.githubusercontent.com/u/545325?v=3","gravatar_id":"","url":"https://api.github.com/users/rguerreiro","html_url":"https://github.com/rguerreiro","followers_url":"https://api.github.com/users/rguerreiro/followers","following_url":"https://api.github.com/users/rguerreiro/following{/other_user}","gists_url":"https://api.github.com/users/rguerreiro/gists{/gist_id}","starred_url":"https://api.github.com/users/rguerreiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rguerreiro/subscriptions","organizations_url":"https://api.github.com/users/rguerreiro/orgs","repos_url":"https://api.github.com/users/rguerreiro/repos","events_url":"https://api.github.com/users/rguerreiro/events{/privacy}","received_events_url":"https://api.github.com/users/rguerreiro/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-01-01T17:27:21Z","updated_at":"2016-01-04T20:46:46Z","closed_at":"2016-01-04T18:25:01Z","body":"The `[SetterProperty]` attribute inside a controller does not work. .\r\n\r\nAfter running the `container.Populate(services)` the build plan for the controller shows nothing (in terms of properties), unless I explicitly add the controller to the container (eg: `For<HomeController>().Use<HomeController>()`). When I do that, the property is injected. In my mind, I shouldn't need to do this. Perhaps the service provider could call `BuildUp()` when getting a controller instance?\r\n\r\nAm I doing anything wrong or this is, in fact, a bug?"},"comment":{"url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/comments/168802145","html_url":"https://github.com/structuremap/structuremap.dnx/issues/6#issuecomment-168802145","issue_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/6","id":168802145,"user":{"login":"khellang","id":582487,"avatar_url":"https://avatars.githubusercontent.com/u/582487?v=3","gravatar_id":"","url":"https://api.github.com/users/khellang","html_url":"https://github.com/khellang","followers_url":"https://api.github.com/users/khellang/followers","following_url":"https://api.github.com/users/khellang/following{/other_user}","gists_url":"https://api.github.com/users/khellang/gists{/gist_id}","starred_url":"https://api.github.com/users/khellang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khellang/subscriptions","organizations_url":"https://api.github.com/users/khellang/orgs","repos_url":"https://api.github.com/users/khellang/repos","events_url":"https://api.github.com/users/khellang/events{/privacy}","received_events_url":"https://api.github.com/users/khellang/received_events","type":"User","site_admin":false},"created_at":"2016-01-04T20:46:46Z","updated_at":"2016-01-04T20:46:46Z","body":"> If that isn't in the docs, how one would know about it? ;)\r\n\r\n@rguerreiro Read the MVC docs? :grin: This repo has nothing to do with MVC. It's an important distinction. It can be used with any other framework. The way the framework calls the adapter is not up to us to document. It's a slippery slope if we start to documenting different frameworks behaviours. You should file an issue in the MVC repo, telling them to provide better documentation. If you ask me, it's a really weird thing; having to call a method for the framework to ask the container for controllers.\r\n\r\n> The only reason that isn't quite working now is that MVC6 gets things through `TryGetInstance` instead of `GetInstance`.\r\n\r\n@jeremydmiller Not really. MVC doesn't even ask the container for the controller type itself. It only asks for the controllers dependencies -- if it has any. By default, it uses the [`DefaultControllerActivator`](https://github.com/aspnet/Mvc/blob/1f8744209263f1c93caec4157b0fa804d99d2e82/src/Microsoft.AspNet.Mvc.Core/Controllers/DefaultControllerActivator.cs), which simply calls a cached compiled lambda (see [`ActivatorUtilities`](https://github.com/aspnet/Common/blob/e9de858fbbc5a26f8ef1906028b67361708e97aa/src/Microsoft.Extensions.ActivatorUtilities.Sources/ActivatorUtilities.cs)).\r\n\r\nIf you want MVC to actually ask the container for the controllers, you need to call `AddControllersAsServices` , which registers all controller types (in a specified collection or assemblies), and then swaps out the `IControllerActivator` service with the [`ServiceBasedControllerActivator`](https://github.com/aspnet/Mvc/blob/1f8744209263f1c93caec4157b0fa804d99d2e82/src/Microsoft.AspNet.Mvc.Core/Controllers/ServiceBasedControllerActivator.cs) (see [`ControllersAsServices`](https://github.com/aspnet/Mvc/blob/1f8744209263f1c93caec4157b0fa804d99d2e82/src/Microsoft.AspNet.Mvc.Core/Internal/ControllersAsServices.cs). Again, this will call `TryGetInstance`, but I'm not sure that's a big deal.\r\n\r\nI'd rather not do any magic in this library, coupling it to MVC, because it's equally as usable with any other framework (not only web) :smile:"}}