Under Windows I have used the SaxonCS library (available on NuGet https://www.nuget.org/packages/SaxonCS/ that is written against .NET 5 successfully in both .NET 5 and .NET 6 applications.
However, now trying some of my .NET code on a Mac M1 I find that using SaxonCS in a .NET 5 application works while an attempt in a .NET 6 application gives no build errors but on attempting to run it gives an error System.BadImageFormatException.
Details are:
dotnet NET6ConsoleApp1.dll
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'SaxonCS, Version=11.2.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
File name: 'SaxonCS, Version=11.2.0.0, Culture=neutral, PublicKeyToken=null'
zsh: abort dotnet NET6ConsoleApp1.dll
Details of used .NET:
dotnet --info
.NET SDK (gemäß "global.json"):
Version: 6.0.200
Commit: 4c30de7899
Laufzeitumgebung:
OS Name: Mac OS X
OS Version: 11.6
OS Platform: Darwin
RID: osx.11.0-arm64
Base Path: /usr/local/share/dotnet/sdk/6.0.200/
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
.NET SDKs installed:
6.0.200 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
In terms of C# code the console app does nothing more than
using Saxon.Api;
Console.WriteLine("{0} {1} {2}", Environment.Version, Environment.OSVersion, Environment.ProcessPath);
Environment.SetEnvironmentVariable("SAXON_LICENSE_DIR", "/Users/username/Library/SaxonCS");
Processor processor = new Processor(true);
Console.WriteLine("{0} {1}", processor.ProductTitle, processor.ProductVersion);
I don't understand why the code runs under Windows with .NET 6 but fails under a Mac M1 ARM.
Does anyone have an explanation? How can I remedy that problem, without having to wait for or ask the library owner to release a .NET 6 version?