{"action":"created","issue":{"url":"https://api.github.com/repos/seesharper/LightInject/issues/281","repository_url":"https://api.github.com/repos/seesharper/LightInject","labels_url":"https://api.github.com/repos/seesharper/LightInject/issues/281/labels{/name}","comments_url":"https://api.github.com/repos/seesharper/LightInject/issues/281/comments","events_url":"https://api.github.com/repos/seesharper/LightInject/issues/281/events","html_url":"https://github.com/seesharper/LightInject/issues/281","id":157685608,"number":281,"title":"Exception System.InvalidOperationException: Attempt to create a scoped instance without a current scope. on first request ","user":{"login":"ivankarpey","id":1046820,"avatar_url":"https://avatars.githubusercontent.com/u/1046820?v=3","gravatar_id":"","url":"https://api.github.com/users/ivankarpey","html_url":"https://github.com/ivankarpey","followers_url":"https://api.github.com/users/ivankarpey/followers","following_url":"https://api.github.com/users/ivankarpey/following{/other_user}","gists_url":"https://api.github.com/users/ivankarpey/gists{/gist_id}","starred_url":"https://api.github.com/users/ivankarpey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivankarpey/subscriptions","organizations_url":"https://api.github.com/users/ivankarpey/orgs","repos_url":"https://api.github.com/users/ivankarpey/repos","events_url":"https://api.github.com/users/ivankarpey/events{/privacy}","received_events_url":"https://api.github.com/users/ivankarpey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-31T14:28:19Z","updated_at":"2016-05-31T14:50:05Z","closed_at":null,"body":"I noticed pretty strange error in my `asp.net core rc2 ` based project. When I first time request my api  Light inject fails with error:\r\n\r\n```\r\n'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\1.0.0-rc2-3002702\\System.ComponentModel.Annotations.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.\r\nMicrosoft.AspNetCore.Server.Kestrel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60:Error: Connection id \"0HKS99PSIDG7Q\": An unhandled exception was thrown by the application.\r\n\r\nSystem.InvalidOperationException: Attempt to create a scoped instance without a current scope.\r\n   at LightInject.PerScopeLifetime.GetInstance(Func`1 createInstance, Scope scope)\r\n   at Microsoft.Extensions.Internal.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)\r\n   at lambda_method(Closure , IServiceProvider , Object[] )\r\n   at Microsoft.AspNetCore.Mvc.Internal.TypeActivatorCache.CreateInstance[TInstance](IServiceProvider serviceProvider, Type implementationType)\r\n   at Microsoft.AspNetCore.Mvc.Controllers.DefaultControllerFactory.CreateController(ControllerContext context)\r\n   at Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeAllActionFiltersAsync>d__40.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeExceptionFilterAsync>d__39.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeAsync>d__32.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler.<InvokeActionAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()\r\nMicrosoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 275.9799ms 200 \r\nThe thread 0x2450 has exited with code 0 (0x0).\r\n```\r\n\r\nand next requests seems working. I play with different lifetimes and scopeManagers, but looks like they wasn't working, since exception each time was from PerScopeLifetime, even if I directly registered with other. \r\n\r\nI implement small project which reproducing an issue - [lightinject_issue](https://github.com/ivankarpey/LightInjectIssue) - hope this will help to resolve the problem fast.\r\n"},"comment":{"url":"https://api.github.com/repos/seesharper/LightInject/issues/comments/222712709","html_url":"https://github.com/seesharper/LightInject/issues/281#issuecomment-222712709","issue_url":"https://api.github.com/repos/seesharper/LightInject/issues/281","id":222712709,"user":{"login":"ivankarpey","id":1046820,"avatar_url":"https://avatars.githubusercontent.com/u/1046820?v=3","gravatar_id":"","url":"https://api.github.com/users/ivankarpey","html_url":"https://github.com/ivankarpey","followers_url":"https://api.github.com/users/ivankarpey/followers","following_url":"https://api.github.com/users/ivankarpey/following{/other_user}","gists_url":"https://api.github.com/users/ivankarpey/gists{/gist_id}","starred_url":"https://api.github.com/users/ivankarpey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivankarpey/subscriptions","organizations_url":"https://api.github.com/users/ivankarpey/orgs","repos_url":"https://api.github.com/users/ivankarpey/repos","events_url":"https://api.github.com/users/ivankarpey/events{/privacy}","received_events_url":"https://api.github.com/users/ivankarpey/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T14:50:05Z","updated_at":"2016-05-31T14:50:05Z","body":"thanks, will be waiting. It's awesome that you replying so fast. I'm appreciated."}}
{"actor":{"display_login":"ivankarpey"}}