{"id":611,"date":"2019-09-24T16:36:55","date_gmt":"2019-09-24T07:36:55","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=611"},"modified":"2019-09-24T16:36:55","modified_gmt":"2019-09-24T07:36:55","slug":"hello-world-startup-capture-errors","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=611","title":{"rendered":"hello-world-startup-capture-errors"},"content":{"rendered":"\n<pre class=\"lang:c# decode:true \" >using Microsoft.AspNetCore.Hosting; \/\/IWebHostBuilder\r\nusing Microsoft.AspNetCore.Builder; \/\/IApplicationBuilder\r\nusing Microsoft.AspNetCore.Http; \/\/WriteAsync\r\nusing Microsoft.AspNetCore; \/\/webHost\r\nusing Microsoft.Extensions.Logging;\/\/ILoggerFactory\r\nusing Microsoft.Extensions.DependencyInjection; \/\/ IServiceCollection\r\nusing Microsoft.Extensions.Primitives; \/\/StringValues\r\nusing System; \/\/Exception\r\n\r\nnamespace WebApplication1\r\n{\r\n    public class Startup\r\n    {\r\n        public Startup(IHostingEnvironment env, ILoggerFactory logger)\r\n        {\r\n            \/\/These are two services available at constructor\r\n        }\r\n\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            throw new Exception(\"error here\");\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)\r\n        {\r\n            app.Run(context =&gt;\r\n            {\r\n                return context.Response.WriteAsync($\"Request {context.Request.Method}\");\r\n            });\r\n        }\r\n    }\r\n\r\n\r\n\r\n    public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            CreateWebHostBuilder(args).Build().Run();\r\n        }\r\n\r\n        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;\r\n            WebHost.CreateDefaultBuilder(args)\r\n             .UseSetting(\"detailedErrors\", \"true\")\r\n                .UseStartup&lt;Startup&gt;()\r\n                .UseEnvironment(\"Development\"); \/\/You can change this to \"Production\" to use StartupProduction\r\n    }\r\n}<\/pre>\n<p>\uacb0\uacfc :<br \/>\nAn error occurred while starting the application.<br \/>\nException: error here<br \/>\nWebApplication1.Startup.ConfigureServices(IServiceCollection services) in Program.cs, line 21<br \/>\nException: error here<br \/>\nWebApplication1.Startup.ConfigureServices(IServiceCollection services) in Program.cs<br \/>\n21.            throw new Exception(&#8220;error here&#8221;);<br \/>\nMicrosoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)<br \/>\nMicrosoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()<br \/>\nMicrosoft.AspNetCore.Hosting.Internal.WebHost.Initialize()<br \/>\nMicrosoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()<br \/>\nShow raw exception details<br \/>\n.NET Core 4.6.28008.02 X64 v4.0.0.0    |   Microsoft.AspNetCore.Hosting version 2.2.7-servicing-10089    |    Microsoft Windows 10.0.18362    |   Need help? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>using Microsoft.AspNetCore.Hosting; \/\/IWebHostBuilder using Microsoft.AspNetCore.Builder; \/\/IApplicationBuilder using Microsoft.AspNetCore.Http; \/\/WriteAsync using Microsoft.AspNetCore; \/\/webHost using Microsoft.Extensions.Logging;\/\/ILoggerFactory using Microsoft.Extensions.DependencyInjection; \/\/ IServiceCollection using Microsoft.Extensions.Primitives; \/\/StringValues using System; \/\/Exception namespace WebApplication1 { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger) { \/\/These are two services available at constructor } public void ConfigureServices(IServiceCollection services) { throw new Exception(&#8220;error here&#8221;); }\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=611\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-611","post","type-post","status-publish","format-standard","hentry","category-net-core"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=611"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":612,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/611\/revisions\/612"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}