Advanced Search

Message “Attempted to read or write protected memory”

Article ID: 1565
Category: Engine Initialization
Type: Hot Fix
Last Modified: 11/15/2013

Why does the “System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” error message appear?


This message usually occurs if you try to access non-existing object or attempt to use Engine from different threads simultaneously.

Engine object is singleton, so it must be initialized, used and deinitialized within one and the same STA thread strictly (default apartment in .Net is MTA). Otherwise program behavior can be unpredictable. This fact is mentioned in FineReader Engine Help, FAQ section "Using the Engine object".


To check how the Engine object is used in your application, you can log current thread ID and apartment state after every Engine method call: ID must be the same and Apartment state must be STA during all the process of Engine usage, from initialization to unloading.

Please make sure that this requirement is fulfilled for your application. If it is not, then you will need to modify your application structure so Engine is definitely used in one STA thread. You can, for example, implement all Engine methods within one separate thread and set this thread apartment state to STA before starting it from service main function.

In case these recommendations will not help, please send an AInfo report and the sample project using which such behavior can be reproduced to ABBYY Technical Support Team.

Related Products:

Advanced Search

Search Knowledge Base:

Still have questions?

Contact ABBYY Support Team

Was this information helpful to you?

Yes No