简体   繁体   中英

.NET Core 3.1 Console App will not run on Windows 7

I created a .NET Core 3.1 AnyCpu Console Application using Visual Studio 2019 with the latest patches. The only code it contains is the boilerplate Console.WriteLine("Hello World!") it was created with. I compile this and it runs fine on my Windows 10 x64 box.

I copy the Debug folder over to my 32-bit Windows 7 box and attempt to run the Console Application. I get the following message. (The.Net Core 3.1 runtime is installed on the Windows 7 box).

The version 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) version of the program, and then contact the software publisher.

However, if I compile the Console Application using x86 then it runs fine on the Windows 7 box. With VS2019 and .NET Core 3/3.1 has AnyCpu changed? I would have expected that code compiled for AnyCpu should have worked fine under 32- and 64-bit.

It looks like there has been a change in the way AnyCpu works in.Net Core 3. In .NET Framework the.exe was a managed exe so with AnyCpu it JIT'ed at runtime to whatever was required x86 or x64 **. In.Net Core using AnyCpu the.Exe is a plain unmanaged exe, compiled for x86 / x64 depending on what architecture your machine doing the compiling is. However, the dll that it creates contains managed code and can be run on a 32bit machine using DotNet.exe.

The solution is not to compile on a 32bit machine as this just launches the dll in 32bit mode. The solution is actually to not use the.exe and launch the dll with the local copy of DotNet.exe.

** source: https://mihai-albert.com/2020/03/08/startup-sequence-of-a-dotnet-core-app/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM