Search code examples
c#finereader

C# memory error on program exit


I have a rather simple C# program (no UI, just command line) that uses a 3rd party library (Abbyy's Finereader 8.1) to do some work and then exits.

Simple enough and works quite well. Recently however we've started getting the following error from the program:

Application Error : The instruction at "0x2c0de46b" referenced memory at "0x0732aa84".

A little digging shows that this is happening at the end of the C# code. Basically the last two lines are:

  Console.WriteLine(message);
  return statusCode;

The final console message is written and the output from the program is fine. Indeed, if it wasn't for the fact that this error keeps the program from fully terminating I could work around it.

We're running two scripts that invoke this program each on two machines. This happens at random (as far as I can tell) but usually at least one of (the 4 scripts) hits this each day. I thought that perhaps some kind of weirdness was happening for concurrent runs, but testing eliminated that.

Any thoughts on possible causes would be most welcome as I've run out of ideas.

Also if anyone knows of a way to have the program terminate when this happens, that would be useful.


Solution

  • "Application Error : The instruction at "0x2c0de46b" referenced memory at "0x0732aa84"."

    This error implies memory corruption somewhere in your code, without the full code i cannot say more than this. The place where the exception is risen is not important in this case of error. Try to take a look at your code, especially the code that calls the library.