C# app "has exited with code -1073741819 (0xc0000005) 'Access violation'" while debugging (winform)

Adarsh 1 Reputation point
2020-12-24T12:25:05.907+00:00

​in winform app after crashing the output is showing....

Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework

The program '[2256] project.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

winform is automatically closed(crashed)

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,159 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,421 Reputation points
    2021-01-01T15:10:05.047+00:00

    Hello @Adarsh

    First thing to check is your model is in sync with the database. If nothing has changed add unhandled exception handling, write to a file and report back what was recorded. I noticed you indicated this has been tried and didn't work but it may be written incorrectly and if not this means the exception type is not caught-able which can happen.

    I have a code sample that comprises of a class project for writing exception information and a simple test app on GitHub. To get both projects, create a batch file, insert the following and run.

    Requires Git to be installed.

    mkdir code  
    cd code  
    git init  
    git remote add -f origin https://github.com/karenpayneoregon/csharp-features  
    git sparse-checkout init --cone  
    git sparse-checkout add ExceptionHandling  
    git sparse-checkout add ThreadExceptionWindowsFormsApp  
    git pull origin master  
    :clean-up  
    del .gitattributes  
    del .gitignore  
    del .yml  
    del .editorconfig  
    del *.md  
    del *.sln  
    

    Otherwise, under debug menu select windows, exception settings and check "Common Language runtime exceptions then rerun the app.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.