{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/976","labels_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/976/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/976/comments","events_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/976/events","html_url":"https://github.com/IdentityServer/Thinktecture.IdentityServer3/issues/976","id":58773164,"number":976,"title":"DI System flawed in cooperation with other IoC Containers","user":{"login":"DerAlbertCom","id":136992,"avatar_url":"https://avatars.githubusercontent.com/u/136992?v=3","gravatar_id":"","url":"https://api.github.com/users/DerAlbertCom","html_url":"https://github.com/DerAlbertCom","followers_url":"https://api.github.com/users/DerAlbertCom/followers","following_url":"https://api.github.com/users/DerAlbertCom/following{/other_user}","gists_url":"https://api.github.com/users/DerAlbertCom/gists{/gist_id}","starred_url":"https://api.github.com/users/DerAlbertCom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DerAlbertCom/subscriptions","organizations_url":"https://api.github.com/users/DerAlbertCom/orgs","repos_url":"https://api.github.com/users/DerAlbertCom/repos","events_url":"https://api.github.com/users/DerAlbertCom/events{/privacy}","received_events_url":"https://api.github.com/users/DerAlbertCom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-24T17:35:05Z","updated_at":"2015-02-24T18:47:21Z","closed_at":null,"body":"I was trying today to use IdentityServer 3 (1.1.1) in an existing application which uses StructureMap as IoC. \r\n\r\nI find no way to tell IdSrv to use them, because of the hardwired Autofac. \r\n\r\nSo i tried other ways. the Factory and the Registrations seems a good place to start. But they have a problem, because the don't work with the current scope of the Autofac Dependency Resolver. \r\n\r\nMy idea is that i can use the current IOwinContext to store and use a Scoped Version of the StructureMap Container and use the in my Registration for the Services.\r\n\r\nFrom my Understanding the \r\n\r\nhttps://github.com/IdentityServer/Thinktecture.IdentityServer3/blob/4a44a9f03879c85bbba50cc04c55fc4311436c1a/source/Core/Configuration/Hosting/AutofacContainerMiddleware.cs should make a Scoped Container, and add the current IOwinContext to the scope.\r\n\r\nThe problem is that the Factory seems not to use the scope version of the IoC Container.\r\n\r\nSo that this\r\n```csharp\r\n            factory.Register<IUserService>(new Registration<IUserService>(dr =>\r\n                {\r\n                    var context = dr.Resolve<IOwinContext>();\r\n                    return null;\r\n                }));\r\n```\r\nand also\r\n```csharp\r\n            factory.UserService = new Registration<IUserService>(dr =>\r\n                {\r\n                    var context = dr.Resolve<IOwinContext>();\r\n                    return null;\r\n                });\r\n```\r\n\r\nfails on dr.Resolve<IOwinContext>() because it is not registered. \r\n\r\nBut without the current IOwinContext, cannot access the request specific instances of the SM-IoC, and use the right LifeCycles.\r\n\r\nAm i missing something here?\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/comments/75819239","html_url":"https://github.com/IdentityServer/Thinktecture.IdentityServer3/issues/976#issuecomment-75819239","issue_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/976","id":75819239,"user":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T18:47:21Z","updated_at":"2015-02-24T18:47:21Z","body":"Your service can have an `OwinEnvironment` injected into it."}}