How find wpf application crash position when Access violation Exception happening?


My application sometimes crash. but the visual studio always just output:

XXAplication return -1073741819 (0xc0000005) 'Access violation'。

So I even don't know which part is crash, or which line is crash. the application is very big. So Is there any way can know or understand the crash position or any way can Debug it?


Sorry guys, Enable : "Common Language Runtime Exceptions" not any help. still just output (0xc0000005) 'Access violation'。

asked on Stack Overflow Jan 13, 2014 by qakmak • edited Jan 13, 2014 by qakmak

3 Answers


Generally it's very hard, a stack trace may not lead you anywhere or it may even mislead you. Even in a native platform like C++ it would be hard, but at least they have tools to help diagnose these problems.

An access violation error means memory corruption. .net is a memory managed platform, so technically it wouldn't be possible.

But it is possible when you or the framework or a 3rd party library uses unsafe code or calls unmanaged APIs. When one of those corrupts memory, an error may not be thrown instantly. The error could surface anywhere else.

What you can do is look through the components you are using and try to upgrade them to the latest versions, or try to temporarily disable/replace them.

In my experience for example the System.DirectoryServices assembly caused a lot of those errors on an old Windows server. We upgraded to a newer Windows and newer .net and haven't seen this error ever since.

answered on Stack Overflow Jan 13, 2014 by fejesjoco

Sounds like you're running the app from VS, so turning on first chance exceptions in the IDE is probably the easiest way to figure out where the error is actually being thrown. If you go to the Debug | Exceptions... menu item, this will bring up a dialog where you can check the "Thrown" checkbox for "Common Language Runtime Exceptions". This will cause the debugger to break where the exception is thrown, even if it is handled by code.

answered on Stack Overflow Jan 13, 2014 by Carlos

In my case, I have an array of an obj1 and I wanted to send it to the server. Inside of my object I have a List of obj2. Inside obj2 I have a reference to obj1. As you probably guess, I have a overflow exception inside my object and System can not convert it to object and Access Violation occurred. Try to find something like this in your new updated codes.

answered on Stack Overflow Jul 15, 2020 by Sadeq Shajary

User contributions licensed under CC BY-SA 3.0