System.Memory Version Conflict in IronOCR on .NET Framework

Curtis Chau
Curtis Chau
Updated: November 5, 2026

On IronOCR versions prior to v2026.4.1 on the .NET Framework, calling IronTesseract().Read() can crash with a System.Memory exception and return empty OCR results just before the failure.

Please note: This issue is fixed in IronOCR v2026.4.1. Upgrade to that version for the permanent fix. This article is for users still on earlier versions.
System.Reflection.TargetInvocationException (mscorlib.dll)
"Exception has been thrown by the target of an invocation"
Text

The crash comes from a version conflict between two System.Memory assemblies loaded into the same application. It shows up even in clean projects and is often preceded by a build warning like:

Found conflicts between different versions of "System.Memory"...
"System.Memory, Version=4.0.1.2" was chosen because it was primary and "System.Memory, Version=4.0.2.0" was not.
Text

Affected versions: 2025.4.4, 2025.9.4, 2025.5.6, 2025.6.8. Resolved in 2026.4.1.

Solution

1. Add a binding redirect

Add an explicit binding redirect to your application's App.config so the runtime always loads the System.Memory version IronOCR expects:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="4.0.2.0" newVersion="4.0.1.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
XML

The redirect forces your application onto System.Memory version 4.0.1.2, which stops the crash and restores correct OCR behavior.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

Read More

Ready to Get Started?

NuGet Downloads 6,411,693Version:2026.11just released