visual-studio-2022.net-7.0windows-arm64

.NET 7 app developed from Arm64 won’t run on x64


I’m developing a .NET 7 app on Windows 11, Arm64. Compiling for “any CPU”. When trying to run the app in X64 computers, I get an error saying “This app can’t run on your PC”. The computer has .NET 7 SDK and runtime installed.

If I compile the app using .NET Framework 4.8 on the Arm64 computer, it works properly on the x64 computer as well. What is the issue with .NET 7 here?


Solution

  • You can try using dotnet to run your compiled dll or publish the app (via the UI or using dotnet publish) providing architecture specific runtime identifier (RID) for example - win-x64. Note the --self-contained parameter which by default is true when RID is specified and the project is an executable one:

    --sc|--self-contained [true|false]

    Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project).

    Which will lead to publishing all components of the app, including the .NET libraries and target runtime (see the corresponding docs). Set it to false to publish framework-dependent executable, for example:

    dotnet publish -r win-x64 --self-contained false
    

    Also you can consider using publish profile files.