WPF application does not work on 32bit OS

hossein tavakoli 471 Reputation points
2022-11-10T21:40:24.717+00:00

I have a WPF project with any cpu platform target.
I run exe file on another laptop with 32bit OS, but it doesn't open and I get this error :
This verison of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) verion of the program.

259205-1.jpg
259222-2.jpg
259148-3.jpg

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,671 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,237 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
762 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lex Li (Microsoft) 4,662 Reputation points Microsoft Employee
    2022-11-11T05:44:13.093+00:00

    The actual cause is much simpler than other answers described.

    When you compile a WPF on .NET 6 project, you have several compilation options,

    • dotnet build -p:Platform=x86
    • dotnet build -p:Platform=x64
    • dotnet build -p:Platform=AnyCPU (usually the default of VS)

    I ignored ARM64 but it's similar.

    You should notice that the output folder contains both yourproject.dll (the actual managed assembly compiled by C# compiler) and yourproject.exe (a native launcher executable).

    So when you copy that folder to another machine, whether yourproject.exe can work or not is fully determined by the bitness of that launcher executable added by .NET 6 SDK. Using dumpbin yourproject.exe /HEADERS you can dump out the bitness information 8664 machine (x64) or 14C machine (x86).

    You can usually get dumpbin for a Developer Command Prompt or Developer PowerShell for Visual Studio.

    Note that .NET 6 SDK adds an x64 launcher executable when you compile the project as AnyCPU (as well as x64). Thus, that executable won't run on a 32 bit machine and triggers the error dialog you saw.

    The solution is also simple, that you compile the project as x86 (so .NET 6 SDK adds an x86 launcher executable). Another option is to use dotnet yourproject.dll if .NET 6 runtime is installed on the 32 bit machine.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. RLWA32 40,286 Reputation points
    2022-11-10T21:59:32.56+00:00

    This is not a new issue. For more information see the open issue at https://github.com/dotnet/sdk/issues/26647

    It appears that you will need to build specifically for x86 if you want to run your application on a 32-bit system.

    0 comments No comments

  2. Hui Liu-MSFT 38,251 Reputation points Microsoft Vendor
    2022-11-11T02:38:09.297+00:00

    Hi,@hossein tavakoli .

    You could try compatibility mode to see if the following steps work for you. If the program is not compatible, then you may try to install and run the program in compatibility mode.

    Use the following steps:

    1) Right click on the Program

    2) Click on Properties

    3) Click on Compatibility tab

    4) Select Run this program in compatibility mode and select Windows Vista or whatever operating system the program was running successfully.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments