Sitecore crashing on startup with “Internal Error In The .NET Runtime”
I vowed to myself that when I found a solution to this issue on startup of Sitecore, that I would share it since I had spent many fruitless hours of searching for someone that had a similar problem.
The Problem
On startup of Sitecore, a window would pop up saying that an exception had occurred in w3wp.exe and would I like to attach a debugger. I would cancel out of it and the site would then load fine, no issues, until the next time I either changed a config file or dll.
There was nothing indicating any error in the Sitecore logs, so I checked the Event Viewer and saw these two messages:
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFC0A9331C3 (00007FFC0A910000) with exit code 80131506.
Faulting application name: w3wp.exe, version: 10.0.17134.1, time stamp: 0xed729d4e
Faulting module name: clr.dll, version: 4.7.3362.0, time stamp: 0x5c2fcfd4
Exception code: 0xc0000005
Fault offset: 0x00000000000231c3
Faulting process ID: 0x4ed4
Faulting application start time: 0x01d4df734a69e7f7
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
I am disappointed in how long it took me to find the issue. I tried the usual steps when getting strange exceptions in Sitecore:
- Google / StackExchange search to see if anyone else has had the issue. The closest I could find was this one, but it didn’t help in this case.
- Did a BeyondCompare diff of my bin directory with a clean install of Sitecore. Changed my package references to match it exactly.
- Deleted all custom .configs and .dll’s
- Deleted all custom marketing definitions
Nothing seemed to work, and I was tearing my hair out.
The Solution
I had duplicate binding redirects in the web.config. They must have been duplicated somehow — probably a NuGet package upgrade. I simply restored the assemblyBinding section from the stock web.config and hey, what do you know, problem solved.
I usually have a specific web.debug.config / web.release.config transform to adjust binding redirects and keep the web.config as stock as possible, but on Sitecore 9.1.0 I found that I didn’t need to add any new ones over the default so I had removed that transform section. I’ve learned my lesson — keep the transform in there in case NuGet doesn’t play nicely.