SharpDx has not been maintained since 2019 so I dont think it supports arm.
Publishing .NET 6 application as Arm64
I had an app that was using .NET Framework 4.8 and I was publishing it as AnyCPU.
Since I migrated to .NET 6, I now have to export the app as x64/arm64.
My issue is that users with arm64 machines are not able to run the arm64 app variant.
They get this exception when running:
An attempt was made to load a program with an incorrect format. (0x8007000B)
System.BadImageFormatException
at MS.Win32.PresentationCore.UnsafeNativeMethods.MilCoreApi.RenderOptions_ForceSoftwareRenderingModeForProcess(Boolean fForce)
at System.Windows.Media.RenderOptions.set_ProcessRenderMode(RenderMode value)
at Myapp.App.App_Startup(Object sender, StartupEventArgs e) in App.xaml.cs:line 156
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
I checked the line that was triggering the issue and found this:
RenderOptions.ProcessRenderMode = MyApp.Util.Settings.All.DisableHardwareAcceleration ? RenderMode.SoftwareOnly : RenderMode.Default;
The app tries to get the settings, calling the settings class from MyApp.Util library.
-----------------------------
This error doesn't make much sense, because the app is being exported as win-arm64 using dotnet.exe publish.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
<PublishDir>bin\Publish\Full\ARM64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>
</Project>
I went and checked the libraries generated using a dependency walker and found that all the DLL's related to the app were generated as i386 instead of ARM64.
Also, some system DLL's were exported like that too.
What's going on here?
How can I detect which library is causing the issue?
Since I don't have an arm64 machine, how can I ask for debugging details from the user?