IronOCR - Resolving OcrInternals Deployment Error in Windows x86 Applications Using a Separate x64 Helper Process
Ocr.ReadScreenShot() uses IronOCR’s AdvancedScan pipeline and is supported only in a Windows x64 process. If your main application must remain x86, use a separate x64 helper process to run ReadScreenShot() and return the OCR result to the x86 application.
This article applies to:
- Product: IronOCR
- Language: C#
- Framework: .NET Framework
- Application type: Windows Forms, Console App, or similar desktop applications
- OS: Windows
- Platform target affected: x86
- Platform target supported for this method: x64
- Related package:
IronOcr.Extensions.AdvancedScan - Related method:
IronTesseract.ReadScreenShot(...)
Symptoms
When running an IronOCR application as x86 and calling ReadScreenShot(), the application may fail with an OcrInternals deployment error.
Example error:
Error while reading a screenshot, Error while deploying OcrInternals for IronOcr:
'Unable to locate 'OcrInternals' in
...\bin\Debug\runtimes\win-x86\native,
...\bin\Debug\runtimes\win.6.2-x86\native,
...\bin\Debug\runtimes\win.6-x86\native,
...\bin\Debug\,
...
nor in an embedded resource.'
Please install the NuGet Package 'IronOcr.Extension.AdvancedScan' when using IronOcr on Windows.
[Issue Code IRONOCR-OCRINTERNALS-DEPLOYMENT-ERROR-WIN]
The error commonly occurs on this line:
var result = ocr.ReadScreenShot(input);
A simplified reproduction may look like this:
var ocr = new IronOcr.IronTesseract();
using (var input = new IronOcr.OcrInput())
{
input.LoadImage("Step_1-5.jpg");
var result = ocr.ReadScreenShot(input);
Console.WriteLine(result.Text);
}
Cause
ReadScreenShot() depends on IronOCR’s AdvancedScan native components. These components are not supported inside a Windows x86 process.
Installing IronOcr.Extensions.AdvancedScan is required for AdvancedScan features, but the application process must also run as x64. Installing the package alone does not make ReadScreenShot() work in an x86 process.
Solution 1: Run the Application as x64
The simplest solution is to change the project platform target to x64.
In Visual Studio:
- Right-click the project.
- Select Properties.
- Go to Build.
- Set Platform target to x64.
- Make sure Prefer 32-bit is unchecked.
- Rebuild and run the project.
This allows ReadScreenShot() to run in a supported x64 process.
Solution 2: Keep the Main App x86 and Use an x64 OCR Helper Process
If the existing application must remain x86, move only the OCR operation into a small x64 helper process.
Recommended structure:
MainWinForms.x86
- .NET Framework Windows Forms app
- Platform target: x86
- Does not run ReadScreenShot() directly
- Calls the x64 helper process
OcrHelper.x64
- .NET Framework Console app
- Platform target: x64
- References IronOCR
- References IronOcr.Extensions.AdvancedScan
- Runs Ocr.ReadScreenShot()
- Returns the OCR result to the main app
This approach allows the existing x86 application to remain unchanged while the AdvancedScan-based OCR operation runs in a supported x64 process.
Example: x86 Application Calling an x64 OCR Helper
The x86 application can call the x64 helper using ProcessStartInfo.
using System;
using System.Diagnostics;
using System.IO;
public static class OcrHelperClient
{
public static string ReadScreenshotWithHelper(string imagePath)
{
string helperExePath = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"OcrHelper.x64",
"OcrHelper.x64.exe"
);
if (!File.Exists(helperExePath))
{
throw new FileNotFoundException("The OCR helper executable was not found.", helperExePath);
}
var startInfo = new ProcessStartInfo
{
FileName = helperExePath,
Arguments = "\"" + imagePath + "\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
using (var process = new Process())
{
process.StartInfo = startInfo;
process.Start();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
if (process.ExitCode != 0)
{
throw new Exception("OCR helper failed: " + error);
}
return output;
}
}
}
Example usage from the x86 application:
string imagePath = @"C:\Images\Step_1-5.jpg";
string text = OcrHelperClient.ReadScreenshotWithHelper(imagePath);
Console.WriteLine(text);
Example: x64 OCR Helper Console App
The helper process should be built as x64 and reference:
IronOcr
IronOcr.Extensions.AdvancedScan
Example helper code:
using System;
using System.IO;
using IronOcr;
namespace OcrHelper.x64
{
internal static class Program
{
private static int Main(string[] args)
{
try
{
if (args.Length == 0)
{
Console.Error.WriteLine("Missing image path argument.");
return 1;
}
string imagePath = args[0];
if (!File.Exists(imagePath))
{
Console.Error.WriteLine("Image file was not found: " + imagePath);
return 2;
}
string licenseKey = Environment.GetEnvironmentVariable("IRONOCR_LICENSE_KEY");
if (!string.IsNullOrWhiteSpace(licenseKey))
{
License.LicenseKey = licenseKey;
}
var ocr = new IronTesseract();
using (var input = new OcrInput())
{
input.LoadImage(imagePath);
var result = ocr.ReadScreenShot(input);
Console.WriteLine(result.Text);
}
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.ToString());
return 99;
}
}
}
}
Notes for Production Use
The sample above uses stdout for simplicity. For production applications, choose the communication method that best fits the application architecture.
Possible options include:
- Standard output / standard error
- Temporary JSON files
- Named pipes
- Local HTTP endpoint
- Windows Service hosting the x64 OCR operation
For small or occasional OCR calls, launching a helper process on demand may be sufficient. For high-volume OCR workloads, a long-running x64 helper service may be more efficient.
Validation Checklist
- The main application is truly required to stay x86.
Ocr.Read()is not good enough for their screenshot OCR scenario.ReadScreenShot()works when executed from an x64 process.- The helper project is built with Platform target: x64.
- The main application is not directly calling
ReadScreenShot()inside the x86 process. IronOcr.Extensions.AdvancedScanis installed in the x64 helper project.- The image path passed to the helper is accessible by the helper process.
- The IronOCR license key is configured either in code, app config, or an environment variable.
Common Mistakes
Installing AdvancedScan but still running x86
Installing IronOcr.Extensions.AdvancedScan is necessary, but it is not enough. The process that calls ReadScreenShot() must be x64.
Calling ReadScreenShot from the x86 application
The x86 application should not call:
ocr.ReadScreenShot(input);
directly. That call must happen inside the x64 helper.
Copying only the helper EXE without dependencies
Make sure the helper output folder includes all required assemblies and native runtime files generated by the build.