Skip to content

[OCR-372] Remove System.Memory dependency to resolve .NET Framework FileLoadException#148

Merged
mee-ironsoftware merged 11 commits intodevelopfrom
ocr-372-alt
Mar 19, 2026
Merged

[OCR-372] Remove System.Memory dependency to resolve .NET Framework FileLoadException#148
mee-ironsoftware merged 11 commits intodevelopfrom
ocr-372-alt

Conversation

@jordi-ironsoftware
Copy link
Copy Markdown
Contributor

@jordi-ironsoftware jordi-ironsoftware commented Feb 24, 2026

Summary

  • Remove explicit System.Memory PackageReference from IronSoftware.Drawing.Common.csproj
  • Update nuspec release notes to document System.Memory removal

Problem

.NET Framework 4.8 customers get FileLoadException when System.Memory assembly version mismatches occur between IronSoftware.Common (declaring 4.6.3 → assembly v4.0.2.0) and SixLabors.ImageSharp (compiled against 4.5.5 → assembly v4.0.1.2).

System.IO.FileLoadException:
Could not load file or assembly 'System.Memory, Version=4.0.1.1,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

5 HubSpot support tickets linked. Affects IronOcr 2025.4, 2025.5, 2025.6.

Root Cause

  • NuGet package version ≠ assembly versionSystem.Memory 4.6.0+ introduces assembly version 4.0.2.0, a breaking change from 4.5.5's 4.0.1.2
  • .NET Framework strict binding demands the exact assembly version compiled against; .NET Core handles mismatches gracefully
  • Previous fix attempt bumped System.Memory to 4.6.3 in IronSoftware.Common.nuspec, which increased the assembly version gap

Fix (this PR)

Remove explicit System.Memory from IronSoftware.Drawing.Common.csproj so that SixLabors.ImageSharp's transitive System.Memory 4.5.5 becomes the single unified version in the dependency graph.

After fix — dependency graph

Consumer App (.NET Framework 4.8)
  ├→ IronSoftware.Common (no explicit System.Memory)
  │    └→ transitive System.Memory >=4.5.4
  │
  └→ IronSoftware.System.Drawing (no explicit System.Memory)
       ├→ SixLabors.ImageSharp      → System.Memory 4.5.5
       └→ Microsoft.Maui.Graphics   → System.Memory 4.5.5

NuGet resolves: System.Memory 4.5.5 (assembly v4.0.1.2) — single version, no conflict ✅

Part of a Multi-Repo Fix

Step Package Status
1 IronSoftware.Common — remove System.Memory from nuspec
2 IronSoftware.Internals — centralized dep versions
3 IronSoftware.Licensing — centralized dep versions
4 IronSoftware.System.Drawing — this PR
5 IronPdf.Core — deps bumped, System.Memory removed from nuspec
6 IronOCR — deps bumped, ZXing downgraded to 0.16.16

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Ran unit tests locally and on Azure
  • Tested with IronOCR in a separate console app on .NET Framework 4.8
  • Verified System.Memory 4.5.5 is the only version in output bin folder

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have successfully run all unit tests on Windows
  • I have successfully run all unit tests on Linux

Fixes OCR-372

Copy link
Copy Markdown
Member

@mee-ironsoftware mee-ironsoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have System.Memory as dependency in many packages. We should remove from all repositories and keep only in IronSoftware.Common to preventing future conflict.

@jordi-ironsoftware
Copy link
Copy Markdown
Contributor Author

@mee-ironsoftware I agree. I'll update accordingly

Copy link
Copy Markdown
Member

@mee-ironsoftware mee-ironsoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another feedback. Please re-test after changing this, I'm afraid it will affect to our product from removing this out from csproj.

@mee-ironsoftware mee-ironsoftware changed the title [OCR-372] Update System.Memory [OCR-372] Remove System.Memory dependency to resolve .NET Framework FileLoadException Mar 17, 2026
@mee-ironsoftware mee-ironsoftware merged commit 3600025 into develop Mar 19, 2026
18 checks passed
@mee-ironsoftware mee-ironsoftware deleted the ocr-372-alt branch March 19, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants