Reputation: 453
I have a .NET 5 WPF application built for AnyCPU platform. In the project file i have: WinExe net5.0-windows
The output folder contains all dll and an exe but when i run the exe on a 32 bits windows i get this message:
This version of software.exe is not compatible with the version of windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
To ease deployment and run, I want to have only 1 build and 1 shortcut no matter the target system. So my initial solution was to run the application using dotnet.exe and having the core dll as a parameter.
dotnet.exe software.dll
The WPF application start and run fine but the console with the dotnet command line is kept open during the application lifetime.
Is there a solution to get rid of the console when I start the WPF application using dotnet.exe ?
Upvotes: 0
Views: 560
Reputation: 2930
To put all this together, a 32-bit machine can run anything with a PE set to PE32, but nothing with a PE of PE32+. A 64-bit machine can run your file in 64-bit mode as long as 32BIT is 0, but if 32BIT is 1 then it must use WOW64.
Why would you want to compile a .NET assembly specific to 32-bit or X64, or IA? Usually because you're P/Invok'ing into a x64 specific native dll. The interesting things that corflags tell us are these:
- CLR Header: The compiler version...2.0 is .NET 1.1, 2.5 is .NET 2.0 and 3.0 is .NET 3.5. Don't ask. ;)
- PE (Portable Executable): PE32 is 32bit and PE32+ is 64-bit.
- 32BIT: Are we asking to force 32-bit execution or not?
Upvotes: 1
Reputation: 453
No solution without exe file at this time, so as a workaround I found a way to produce both 32bit and 64bit exe.
In the Visual Studio build configuration manager, I added x86 and x64 platforms. Which updated the csproj with
<Platforms>AnyCPU;x86;x64</Platforms>
Then I added in csproj
<AssemblyName>MySoftware-$(Platform)</AssemblyName>
When I build the solution, it automatically append the targeted platform to the exe and dll for the platform.
MySoftware-x86.exe
MySoftware-x86.dll
MySoftware-x64.exe
MySoftware-x64.dll
Finally, I call "dotnet.exe build" twice for both x86 and x64 using a script.
Upvotes: 1