﻿<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://developers.de/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Holger's Blog : Core.Net</title><link />http://developers.de/blogs/holger_vetter/archive/tags/Core.Net/default.aspx<description>Tags: Core.Net</description><dc:language>en</dc:language><generator>CommunityServer 2008 SP1 (Build: 30619.63)</generator><item><title>Identify ASP.Net Core startup errors</title><link />http://developers.de/blogs/holger_vetter/archive/2016/11/30/identify-asp-net-core-startup-errors.aspx<pubdate>Wed, 30 Nov 2016 15:31:00 GMT</pubdate><guid ispermalink="false">7e491611-45ad-4dae-a68f-c4cb64439510:1803047</guid><dc:creator>Holger Vetter</dc:creator><slash:comments>9</slash:comments><wfw:commentrss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://developers.de/blogs/holger_vetter/rsscomments.aspx?PostID=1803047</wfw:commentrss><comments>http://developers.de/blogs/holger_vetter/archive/2016/11/30/identify-asp-net-core-startup-errors.aspx#comments</comments><description>&lt;p&gt;Maybe you know this great and informative error message &amp;quot;An error occurred while starting the application.&amp;quot; from asp.net core when there was an exception during the startup.
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/113016_5F00_1531_5F00_IdentifyASP1.png" alt="" /&gt;
	&lt;/p&gt;
&lt;p&gt;To identify and understand what happened, you must extend the Main method with the following things:
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/113016_5F00_1531_5F00_IdentifyASP2.png" alt="" /&gt;
	&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UseSetting(&amp;quot;detailedErrors&amp;quot;, &amp;quot;true&amp;quot;)
&lt;/li&gt;
&lt;li&gt;CaptureStartupErrors(true)
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After this is done, you will see a nice and detailed error page like this:
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/113016_5F00_1531_5F00_IdentifyASP3.png" alt="" /&gt;
	&lt;/p&gt;
&lt;p&gt;In my case the startup error was a missing json file which the application tried to load on startup.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://developers.de/aggbug.aspx?PostID=1803047" width="1" height="1"&gt;</description><category domain="http://developers.de/blogs/holger_vetter/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://developers.de/blogs/holger_vetter/archive/tags/Core.Net/default.aspx">Core.Net</category></item><item><title>ASP.NET Core returns StatusCode:500</title><link />http://developers.de/blogs/holger_vetter/archive/2016/11/10/asp-net-core-returns-statuscode-500.aspx<pubdate>Thu, 10 Nov 2016 12:56:24 GMT</pubdate><guid ispermalink="false">7e491611-45ad-4dae-a68f-c4cb64439510:1802216</guid><dc:creator>Holger Vetter</dc:creator><slash:comments>0</slash:comments><wfw:commentrss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://developers.de/blogs/holger_vetter/rsscomments.aspx?PostID=1802216</wfw:commentrss><comments>http://developers.de/blogs/holger_vetter/archive/2016/11/10/asp-net-core-returns-statuscode-500.aspx#comments</comments><description>&lt;p&gt;I ported an MVC WEB API project to ASP.NET Core and now the Service just returned StatusCode: 500 every time I called it.
&lt;/p&gt;&lt;p&gt;Visual Studio doesn&amp;#39;t give me any information or Exception to indicate what happened. 
&lt;/p&gt;&lt;p&gt;To find the error I disabled &amp;quot;Enable just my Code&amp;quot; in the visual studio settings.
&lt;/p&gt;&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/111016_5F00_1328_5F00_ASPNETCorer1.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;Now the visual studio showed this exception from the framework, when I call the service:&lt;br /&gt;&amp;quot;Multiple constructors accepting all given argument types have been found in type &amp;quot;…&amp;quot;. There should only be one applicable constructor&amp;quot;.
&lt;/p&gt;&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/111016_5F00_1328_5F00_ASPNETCorer2.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/111016_5F00_1328_5F00_ASPNETCorer3.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;This error indicates that we have multiple constructors, which accepts same argument types. But this wasn&amp;#39;t the case, I just removed the empty constructor and it worked fine.
&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/111016_5F00_1328_5F00_ASPNETCorer4.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;One was the empty constructor I had before in my ASP.NET WEB API application and the other one was for ASP.NET Core.&lt;br /&gt;I just removed the empty one and it worked fine &lt;span style="font-family:Wingdings;"&gt;J&lt;/span&gt;
	&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;Recap: Don&amp;#39;t use multiple constructors when injection IOptions.
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://developers.de/aggbug.aspx?PostID=1802216" width="1" height="1"&gt;</description><category domain="http://developers.de/blogs/holger_vetter/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://developers.de/blogs/holger_vetter/archive/tags/Core.Net/default.aspx">Core.Net</category></item><item><title>.NET Core json settings and environment variable</title><link />http://developers.de/blogs/holger_vetter/archive/2016/10/19/net-core-json-settings-and-environment-variable.aspx<pubdate>Wed, 19 Oct 2016 15:19:52 GMT</pubdate><guid ispermalink="false">7e491611-45ad-4dae-a68f-c4cb64439510:1800873</guid><dc:creator>Holger Vetter</dc:creator><slash:comments>0</slash:comments><wfw:commentrss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://developers.de/blogs/holger_vetter/rsscomments.aspx?PostID=1800873</wfw:commentrss><comments>http://developers.de/blogs/holger_vetter/archive/2016/10/19/net-core-json-settings-and-environment-variable.aspx#comments</comments><description>&lt;p&gt;Today we deployed .NET Core application on a test machine and then configured the application as environmental variable in the system.
&lt;/p&gt;&lt;p&gt;When we started the command line application, it couldn&amp;#39;t find &amp;#39;settings.json&amp;#39; file for reading the configuration.
&lt;/p&gt;&lt;p&gt;This happens because the application looks for it on the relative path where the command was executed.&lt;br /&gt;For example application is in C:\Temp\tool.exe and you run enter &amp;#39;tool&amp;#39; while in &amp;#39;C:\Users\hvetter&amp;#39;, the application will start but will not found your settings file because it searches it in &amp;#39;C:\Users\hvetter&amp;#39; folder instead of &amp;#39;C:\Temp\&amp;#39;.&lt;br /&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/101916_5F00_1524_5F00_NETCorejson1.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;This is the code we used to load the settings file and the output in the Commandline.
&lt;/p&gt;&lt;p&gt;SETTINGS_FILE_NAME is a constant and equals &amp;#39;settings.json&amp;#39;.
&lt;/p&gt;&lt;p&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/101916_5F00_1524_5F00_NETCorejson2.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;It searched &amp;#39;settings.json&amp;#39; file in relative wrong folder.
&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;I changed the code to this for testing and added the output to show what happened.&lt;br /&gt;&lt;img src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/holger_5F00_vetter/101916_5F00_1524_5F00_NETCorejson3.png" alt="" /&gt;
	&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Recap: Don&amp;#39;t use relative paths in .Net Core for loading your settings :)&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://developers.de/aggbug.aspx?PostID=1800873" width="1" height="1"&gt;</description><category domain="http://developers.de/blogs/holger_vetter/archive/tags/Core.Net/default.aspx">Core.Net</category></item></channel></rss>