Our Blog

If you are using .NET Core and have not received the following error/exception message I will send you $1.00.  Let me know!

HTTP Error 500.30 - ANCM In-Process Start Failure
Common solutions to this issue:
  • The application failed to start
  • The application started but then stopped
  • The application started but threw an exception during startup
Troubleshooting steps:
  • Check the system event log for error messages
  • Enable logging the application process' stdout messages
  • Attach a debugger to the application process and inspect

I have ran into this plenty of times already.  There are many reasons but at it’s root dotnet is not able to start up for one of many reasons.  As I run into my issues I will update this post with them.

So far, with ASP.NET Core 3.1.1

1. The IIS Application Pool – Advanced Settings “Enable 32-Bit Applications” – setting to False fixed my issue (this site was deployed to an on-premise IIS Server)

2. Azure installation – It was more difficult to identify the source of the issue as I was not working directly with IIS (Internet Information Server).  I first tried logging via App Service Logs,  and view the streaming logs which led me to error message similar to..

”IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.</li>     <li>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.”

I then worked towards running the web application from command line to hope it gave me more information. i.e. Diagnostic Console – Debug Console then running the web assembly via “dotnet web.dll” (in this case my application was called Web).  This gave me a much better startup.cs issue. I had good sense to recognize the issue/exception was within my startup class.  I had my first real clue from the following message…

”Unhandled exception. System.IO.DirectoryNotFoundException: D:\home\site\wwwroot\Scripts\ at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root) at Web.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, LinkGenerator lin”

image

I had used in prior 2.1 Core solution a scripts static directly which did not exist with this 3.1 solution.

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "Scripts")),
    RequestPath = "/Scripts"
});

Once I removed this reference to /Scripts things worked and I was up and running. 

So, just note that this ANCM error is pretty good indication that something is wrong with Startup.cs class and so you really will be looking for logs for some indication as to what.

image

In .NET there are 6 ways to compare strings.  Really? Why is it so difficult?

Ordinal

Performs a simple byte comparison that is independent of language. This is most appropriate when comparing strings that are generated programmatically or when comparing case-sensitive resources such as passwords.

OrdinalIgnoreCase

Treats the characters in the strings to compare as if they were converted to uppercase using the conventions of the invariant culture, and then performs a simple byte comparison that is independent of language. This is most appropriate when comparing strings that are generated programmatically or when comparing case-insensitive resources such as paths and filenames.

InvariantCulture

Compares strings in a linguistically relevant manner, but it is not suitable for display in any particular culture. Its major application is to order strings in a way that will be identical across cultures.

InvariantCultureIgnoreCase

Compares strings in a linguistically relevant manner that ignores case, but it is not suitable for display in any particular culture. Its major application is to order strings in a way that will be identical across cultures.

CurrentCulture

Can be used when strings are linguistically relevant. For example, if strings are displayed to the user, or if strings are the result of user interaction, culture-sensitive string comparison should be used to order the string data.

CurrentCultureIgnoreCase

Can be used when strings are linguistically relevant but their case is not. For example, if strings are displayed to the user but case is unimportant, culture-sensitive, case-insensitive string comparison should be used to order the string data.

Tip: You should always specify explicitly the comparer as the default value is not consistent. For instance, string.IndexOf uses the current culture whereas string.Equals uses Ordinal.

i.e.

string.Equals("", "", StringComparison.Ordinal);
new [] { "" }.Contains("", StringComparer.Ordinal);
new Dictionary(StringComparer.Ordinal);

</string,>

Refer to blog for additional samples and Rosyln analyzer to help with coding within your IDE.

About Us

Web/Mobile Solutions

Our Contacts

Cincinnati, OH 45069