0

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?

nihar
  • 93
  • 6
  • 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. – jdweng Aug 29 '22 at 11:16
  • It looks like you fixed one issue and then got a second issue. – jdweng Aug 29 '22 at 11:23

1 Answers1

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
magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • also if non-msix output is required add -p:WindowsPackageType=None – nihar Sep 01 '22 at 05:11
  • 1
    yes, but there is still a [lot of work to be done my the MAUI team](https://github.com/dotnet/maui/issues/3166) to fully support this. Currently it is better to use MSIX – magicandre1981 Sep 01 '22 at 05:26