{"action":"created","issue":{"url":"https://api.github.com/repos/ninject/Ninject/issues/215","repository_url":"https://api.github.com/repos/ninject/Ninject","labels_url":"https://api.github.com/repos/ninject/Ninject/issues/215/labels{/name}","comments_url":"https://api.github.com/repos/ninject/Ninject/issues/215/comments","events_url":"https://api.github.com/repos/ninject/Ninject/issues/215/events","html_url":"https://github.com/ninject/Ninject/issues/215","id":168967337,"number":215,"title":"ToMethod Request Target null using lazy dependency","user":{"login":"satuday","id":4556198,"avatar_url":"https://avatars0.githubusercontent.com/u/4556198?v=4","gravatar_id":"","url":"https://api.github.com/users/satuday","html_url":"https://github.com/satuday","followers_url":"https://api.github.com/users/satuday/followers","following_url":"https://api.github.com/users/satuday/following{/other_user}","gists_url":"https://api.github.com/users/satuday/gists{/gist_id}","starred_url":"https://api.github.com/users/satuday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satuday/subscriptions","organizations_url":"https://api.github.com/users/satuday/orgs","repos_url":"https://api.github.com/users/satuday/repos","events_url":"https://api.github.com/users/satuday/events{/privacy}","received_events_url":"https://api.github.com/users/satuday/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-02T19:24:11Z","updated_at":"2017-09-24T07:03:49Z","closed_at":null,"author_association":"NONE","body":"When uisng ToMethod() with lazy<> dependency, the Context.Request.Target is null.\n\n`using Ninject;\nusing System;\n\nnamespace testNinject\n{\n    public class TestClass : ITestClass\n    {\n        private Type declaringType;\n\n```\n    public TestClass(Type declaringType)\n    {\n        this.declaringType = declaringType;\n        Console.WriteLine(declaringType.ToString());\n    }\n\n    public void TestMethod()\n    {\n\n    }\n}\n\npublic class TestService : ITestService\n{\n    public TestService(Lazy<ITestClass> testClass)\n    {\n        var test = testClass;\n        test.Value.TestMethod();\n    }\n\n}\n\npublic interface ITestService2\n{\n\n}\n\npublic class testService2 : ITestService2\n{\n    public testService2(ITestClass testClass)\n    {\n        var test = testClass;\n    }\n}\n\npublic interface ITestService\n{\n\n}\n\npublic interface ITestClass\n{\n    void TestMethod();\n}\n\nclass Program\n{\n    static IKernel kernel = new Ninject.StandardKernel();\n\n    static void Main(string[] args)\n    {\n        kernel.Bind<ITestClass>().\n            ToMethod(x =>\n```\n\n   new TestClass(\n       x.Request.Target == null ? typeof(string) : x.Request.Target.Member.DeclaringType));\n\n```\n        kernel.Bind<ITestService>().To<TestService>();\n        kernel.Bind<ITestService2>().To<testService2>();\n\n        testInject();\n\n        Console.ReadKey();\n    }\n\n    static void testInject()\n    {\n\n        var testService = kernel.Get<ITestService>();\n        var testService2 = kernel.Get<ITestService2>();\n\n\n    }\n}\n```\n\n}\n`\n"},"comment":{"url":"https://api.github.com/repos/ninject/Ninject/issues/comments/331691683","html_url":"https://github.com/ninject/Ninject/issues/215#issuecomment-331691683","issue_url":"https://api.github.com/repos/ninject/Ninject/issues/215","id":331691683,"user":{"login":"scott-xu","id":1913505,"avatar_url":"https://avatars2.githubusercontent.com/u/1913505?v=4","gravatar_id":"","url":"https://api.github.com/users/scott-xu","html_url":"https://github.com/scott-xu","followers_url":"https://api.github.com/users/scott-xu/followers","following_url":"https://api.github.com/users/scott-xu/following{/other_user}","gists_url":"https://api.github.com/users/scott-xu/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-xu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-xu/subscriptions","organizations_url":"https://api.github.com/users/scott-xu/orgs","repos_url":"https://api.github.com/users/scott-xu/repos","events_url":"https://api.github.com/users/scott-xu/events{/privacy}","received_events_url":"https://api.github.com/users/scott-xu/received_events","type":"User","site_admin":false},"created_at":"2017-09-24T07:03:49Z","updated_at":"2017-09-24T07:03:49Z","author_association":"MEMBER","body":"Can you please try Ninject.Extensions.Factory and Ninject.Extensions.ContextPreservation"}}
{"actor":{"display_login":"scott-xu"}}