Miniver Cheevy
Miniver Cheevy

Reputation: 1677

Managed Debugging Assistant 'FatalExecutionEngineError' 0xc0000005

Managed Debugging Assistant 'FatalExecutionEngineError' : 'The runtime has encountered a fatal error. The address of the error was at 0x641ad419, on thread 0x5d0c. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.'

This only seems to happen using Asp.Net Core 1.1 and only with entity framework for .net (not EF Core). It also does not happen all of the time, but when it does it's always during an EF call.

I've tried enabling "Use Managed Compatibility Mode" as described here, but it doesn't seem to make a difference.

Upvotes: 6

Views: 5311

Answers (2)

Christoph
Christoph

Reputation: 3642

I had an issue similar to @RedBottleSanitizer, when entering the Main method before the first line was executed it already crashed the debugger of a normal WPF application (using VS2022 Enterprise 17.11.3 and NET 4.8).

To give the runtime a chance to load my Main method, even if some referenced assemblies should be missing, I decided to move its content into a method Main2 and have in the Main method only a call to Main2, wrapped in a try/catch:

[STAThread]
public static void Main(string[] args) {
    try {
        Main2(args);
    } catch (Exception ex) {
        ; //Set break-point here
    }
}

private static void Main2(string[] args) {
    //Original code from main
}

To my astonishment that didn't give me an exception with a better error message but it solved the problem!

Upvotes: 0

RedBottleSanitizer
RedBottleSanitizer

Reputation: 93

I was getting "FatalExecutionEngineError' : 'The runtime has encountered a fatal error. The address of the error was at 0x72d41302, on thread 0x4520. The error code is 0xc0000005" while running a simple hello world application in Visual Studio 2017.

Resolved the issue by using x64 mode for debug.

Upvotes: 2

Related Questions