Skip to content
English
  • There are no suggestions because the search field is empty.

[Public] IronOCR + ClickOnce: Fixing Missing Secondary Language Files in Published Projects

Overview

When publishing a .NET 8.0 Console Application that uses IronOCR with a secondary language pack (e.g., Spanish, Japanese), developers may find that the published application throws a runtime error due to missing language data files — even though the application runs correctly in Visual Studio.

This issue occurs because ClickOnce does not automatically include secondary language .ocrdata files in the publish output unless explicitly configured.


The Issue: Missing .ocrdata Files


 Result: Runtime Error

The app crashes with:

IronOcr.Exceptions.LanguagePackException:
Please install the Nuget Package IronOcr.Languages.Spanish...
Error: 'The file Spanish.ocrdata was not found'

 

This happens because ClickOnce only publishes what it explicitly knows about, and the secondary language .ocrdata files are not automatically recognized or bundled.


The Solution: Manually Include Language Pack Files

To ensure the secondary language pack is included in your ClickOnce deployment, you need to explicitly mark it for publishing.


Option 1: Add the Language Pack Folder to Your Project

  1. Locate the .ocrdata files — typically found in your build output folder:

     
    bin\Debug\net8.0\OcrData

     

  2. For each file inside the OcrData folder:

    • Set Build Action to Content

    • Set Copy to Output Directory to Copy if newer

This ensures the files:

  • Are copied to the build folder

  • Are included in ClickOnce's publish process


Option 2: Add to .csproj (Recommended for Dynamic Content)

If the folder is auto-generated or large, edit your .csproj to include all .ocrdata files recursively:

<ItemGroup>
  <Content Include="OcrData\**\*">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

This is ideal when you don’t want to manually manage file references in the UI.