How to build x86 (32-bit) version of .NET MAUI App?
Asked Answered
H

1

1

We have a legacy 32-bit C++ dll that we want to use in the .NET MAUI app. The Android version (.so) of this library is working fine. But while trying to load the dll on Windows it fails with following error.

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)

64-bit app and 32-bit dll can be solved using WCF or Remoting, but these solutions are not workable for our scenario.

We need to build the .NET MAUI app as 32-bit x86 app, but we haven't found any documentation regarding same.

Tried adding the following by manually editing the csproj file -

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>

But it broke the build with an seemingly unrelated error error NETSDK1135: SupportedOSPlatformVersion 10.0.19041.0 cannot be higher than TargetPlatformVersion 10.0.17763.0.

Any directions or samples available anywhere?

Hatchel answered 29/8, 2022 at 11:6 Comment(2)
The easiest was of fixing a version issue is to use Solution Explorer in VS. Delete the older version of the dll in References. Then Add the Reference again by using menu Project : Add Reference. The issue is the install version of the dll on machine doesn't match the version in the csproj file. The csproj is text and you can open with notepad to see current version.Matthaeus
It looks like you fixed one issue and then got a second issue.Matthaeus
E
2

Pass -r win10-x86 to the publish commandline to set the RID to 32 bit Windows 10:

dotnet publish -f net6.0-windows10.0.19041.0 -c Release -r win10-x86
Elsie answered 31/8, 2022 at 7:6 Comment(2)
also if non-msix output is required add -p:WindowsPackageType=NoneHatchel
yes, but there is still a lot of work to be done my the MAUI team to fully support this. Currently it is better to use MSIXElsie

© 2022 - 2024 — McMap. All rights reserved.