{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/712","repository_url":"https://api.github.com/repos/aspnet/Hosting","labels_url":"https://api.github.com/repos/aspnet/Hosting/issues/712/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Hosting/issues/712/comments","events_url":"https://api.github.com/repos/aspnet/Hosting/issues/712/events","html_url":"https://github.com/aspnet/Hosting/issues/712","id":149279872,"number":712,"title":"Startup fails when static method is passed to WebHostBuilder.Configure","user":{"login":"nil4","id":139133,"avatar_url":"https://avatars.githubusercontent.com/u/139133?v=3","gravatar_id":"","url":"https://api.github.com/users/nil4","html_url":"https://github.com/nil4","followers_url":"https://api.github.com/users/nil4/followers","following_url":"https://api.github.com/users/nil4/following{/other_user}","gists_url":"https://api.github.com/users/nil4/gists{/gist_id}","starred_url":"https://api.github.com/users/nil4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nil4/subscriptions","organizations_url":"https://api.github.com/users/nil4/orgs","repos_url":"https://api.github.com/users/nil4/repos","events_url":"https://api.github.com/users/nil4/events{/privacy}","received_events_url":"https://api.github.com/users/nil4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/Hosting/labels/3%20-%20Done","name":"3 - Done","color":"CCCCCC"},{"url":"https://api.github.com/repos/aspnet/Hosting/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"davidfowl","id":95136,"avatar_url":"https://avatars.githubusercontent.com/u/95136?v=3","gravatar_id":"","url":"https://api.github.com/users/davidfowl","html_url":"https://github.com/davidfowl","followers_url":"https://api.github.com/users/davidfowl/followers","following_url":"https://api.github.com/users/davidfowl/following{/other_user}","gists_url":"https://api.github.com/users/davidfowl/gists{/gist_id}","starred_url":"https://api.github.com/users/davidfowl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidfowl/subscriptions","organizations_url":"https://api.github.com/users/davidfowl/orgs","repos_url":"https://api.github.com/users/davidfowl/repos","events_url":"https://api.github.com/users/davidfowl/events{/privacy}","received_events_url":"https://api.github.com/users/davidfowl/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/Hosting/milestones/18","html_url":"https://github.com/aspnet/Hosting/milestones/1.0.0-rc2","labels_url":"https://api.github.com/repos/aspnet/Hosting/milestones/18/labels","id":1371266,"number":18,"title":"1.0.0-rc2","description":null,"creator":{"login":"muratg","id":1808428,"avatar_url":"https://avatars.githubusercontent.com/u/1808428?v=3","gravatar_id":"","url":"https://api.github.com/users/muratg","html_url":"https://github.com/muratg","followers_url":"https://api.github.com/users/muratg/followers","following_url":"https://api.github.com/users/muratg/following{/other_user}","gists_url":"https://api.github.com/users/muratg/gists{/gist_id}","starred_url":"https://api.github.com/users/muratg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muratg/subscriptions","organizations_url":"https://api.github.com/users/muratg/orgs","repos_url":"https://api.github.com/users/muratg/repos","events_url":"https://api.github.com/users/muratg/events{/privacy}","received_events_url":"https://api.github.com/users/muratg/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":72,"state":"open","created_at":"2015-10-22T21:04:09Z","updated_at":"2016-04-20T17:56:12Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-04-18T21:39:23Z","updated_at":"2016-04-21T15:05:52Z","closed_at":"2016-04-19T17:05:33Z","body":"```csharp\r\nusing System;\r\nusing Microsoft.AspNetCore.Builder;\r\nusing Microsoft.AspNetCore.Hosting;\r\n\r\nstatic class Program {\r\n    static void Main(string[] args) => new WebHostBuilder()\r\n        .UseKestrel()\r\n        .Configure(ConfigureApplication)\r\n        .Build().Run();\r\n\r\n    static void ConfigureApplication(IApplicationBuilder app) {}\r\n}\r\n```\r\n\r\nExpected: the application starts up and `ConfigureApplication` is called.\r\n\r\nActual: the application crashes on startup with stack trace:\r\n\r\n```\r\nUnhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at System.Object.GetType()\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.ResolveApplicationName()\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildHostingServices()\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()\r\n   at Program.Main(String[] args) in D:\\projects\\Repro\\Program.cs:line 6\r\n```\r\n\r\nIn [`WebHostBuilder.ResolveApplicationName`](https://github.com/aspnet/Hosting/blob/4e5fd908fd5eb33f55cf90f852f3328468e64e2a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L257), `_startup.ConfigureDelegate.Target` is assumed to be non-null. This assumption is invalid for static methods. "},"comment":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/comments/212962869","html_url":"https://github.com/aspnet/Hosting/issues/712#issuecomment-212962869","issue_url":"https://api.github.com/repos/aspnet/Hosting/issues/712","id":212962869,"user":{"login":"EricABC","id":13154635,"avatar_url":"https://avatars.githubusercontent.com/u/13154635?v=3","gravatar_id":"","url":"https://api.github.com/users/EricABC","html_url":"https://github.com/EricABC","followers_url":"https://api.github.com/users/EricABC/followers","following_url":"https://api.github.com/users/EricABC/following{/other_user}","gists_url":"https://api.github.com/users/EricABC/gists{/gist_id}","starred_url":"https://api.github.com/users/EricABC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricABC/subscriptions","organizations_url":"https://api.github.com/users/EricABC/orgs","repos_url":"https://api.github.com/users/EricABC/repos","events_url":"https://api.github.com/users/EricABC/events{/privacy}","received_events_url":"https://api.github.com/users/EricABC/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T15:05:52Z","updated_at":"2016-04-21T15:05:52Z","body":"@davidfowl I see this gets an overhaul in the dev branch, but for the release is there any chance you might consider moving the _options.Application to the top of ResolveApplicationName for release (which closer matches the dev branch already)? [L265](https://github.com/aspnet/Hosting/blob/release/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L265).  The problem I encounter is when abstracting out some of the startup process for several apps with common configuration.  It ends up leading to somewhat cryptic routing 404's and 'view not found' in MVC because Build() will set the IHostingEnvironment ApplicationName based on a delegate living in a base type outside the entry assembly.  Because Build() always calls this first [here](https://github.com/aspnet/Hosting/blob/release/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L183) there is no way I can find to set the name to the actual entry assembly before HostingEnvironment.Initialize is called.  Its not that it can't be worked around, the but workarounds would be needed for each front end app.\r\n\r\nThanks for considering:)"}}