How to remove c0000005 exception from native dll in C #

I am working with a native dll that throws an exception c0000005 (access violation) somewhere and ends up crashing my web service until the service is reworked. Is there a way to catch the exception?

+2


source to share


3 answers


you can catch the exception using Microsoft's SEH exception handler , but in reality you have to fix whatever is wrong.



Cheers and hth.,

+3


source


Don't get this. Correct the mistake.

0xc0000005

is the NT error code for STATUS_ACCESS_VIOLATION

. This means that your program did different parsing of pointers. In simpler terms, this means that your program crashed badly and the attempt to restore was wrong.



I know you are saying this is a third party DLL, but at least you should debug and understand the problem. It might be something as simple as you are passing some bad input to the DLL or not initializing it properly. If you cannot do this, you can contact the DLL authors or consider removing the dependency on them.

+2


source


I agree with others ... Fix the problem, but sometimes you inherit from code and you just want to catch an unexpected breach in production.

In .net 4+, you can add HandleProcessCorruptedStateExceptions attribute and it will throw as an exception you can catch. The call stack is not very useful, but better than nothing.

FROM#

[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions]
public void SomeCSharpMethod()
try
{
  // call managed code
}
catch (Exception ex)
{
  Console.WriteLine("Exception");
}

      

C ++

vector<int> myValues;
int a = myValues[1];

      

+2


source







All Articles