Will a UWP app built for x86 run on x64? - c#

I'm having a problem, and found a suggestion to build for x86 only. But I'm not sure, though x86 can run on x64 computers, does that mean it will run as a UWP app as well, and be offered to x64 clients?
The docs weren't clear.

TL;DR: An x86 only UWP app will run on Windows x64 consumer systems, but won't run on Xbox One or older Windows ARM-based devices.
Generally speaking modern Windows x64 desktop PCs have the "Windows-on-Windows" layer which supports running 32-bit applications as well as 64-bit native apps for improved compatibility. That said, there are 64-bit versions of Windows that do not support running 32-bit apps like Windows Server (it's an optional feature) or Xbox One (which can only run x64 native apps). In these cases, a UWP package with only x86 would not run.
x86 and ARM has to date mostly been relevant to Windows Mobile platforms. There are some recently released Windows 10 on ARM devices entering the market that can run x86 or ARM, but not x64 applications.
x64 works on most Windows desktop PCs and Xbox One. Depending on the exact market segment you are targeting and your application type, you could go with just an x64 only architecture package--this is mostly relevant to high-end games or heavy performance applications.
Ideally you would ship your UWP app for all supported architectures including x86, x64 native, and ARM assuming you are able to actually test them all.
See Windows 64, UWP on Xbox One, and DirectX and UWP on Xbox One

an x86 build will NOT run on
1) windows rt/Windows S
2) xbox.
3) any windows mobile variant.
it will run on
1) windows for desktop either natively or under the WOW architecture. both 32 and 64 bit versions.
2) windows 10 for ARM 64 bit os (via win32 emulation layer under WOW.) any device that has this OS will work.
3) Hololens (requires x86)
4) IOT Core, depending on your device.
5) Surface Hub (whatever that is)
By now you can also compile arm64, which only runs on windows 10 for ARM.

Related

When it's needed to use x86 or x64 target platform?

I've studied the information about building apps with a different target platforms options in visual studio, but I still can't understand the following things:
when do we need to set x86 or x64 target?
what advantages gives us setting a specific target platform (x86 or x64) over setting 'any cpu'?
isn't it easier always to set 'any cpu'?
There are three options in the platfrom target as of now. x86, x64, Any CPU. To complicate thing even worse, there is a checkbox called "Prefer 32bit".
When you are developing applications you have to make sure its Any CPU is Enabled and Prefer 32bit is disabled for maximum compatibility.
However some times you will be using native calles to platfrom specific APIs (eg: you are calling a 32bit native dll). Then enabling Any CPU will run your application as 64bit process in a 64bit operating system. This will indroduce exceptions in the runtime. You should be targeted to x86 platform. Same goes for 64 bit native calles, you should target it as x64 only.
Lets see why Prefer 32bit is there. Windows has a new target type called ARM (Windows 8 ARM 32bit as of the date Prefer 32bit is introduced). When this option is enabled and Any CPU is selected. A .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully.
Going forwards disable Prefer 32bit since nobody used Windows 8 ARM. Windows 10 ARM have resolved this issue.

Detecting if CPU is 64bit in Universal App (Windows)

I have a universal app that uses PlayReady DRM protected videos. The problem with PlayReady is that it only work if the application build architecture matches the CPU architecture (e.g: ARM build on ARM, x64 on 64bit CPU, x86 on 32bit CPU). This is by design (for some reason).
So the problem is, if a user has a 64bit CPU and runs a 32bit OS. In this case, he gets the x86 build from the store (because of 32bit OS) but PlayReady will not work because of the 64bit CPI vs X86 build mismatch. In this case, I want to display a message (instead of just failing to play the video).
I can detect easily detect x86 build (by adding a conditional symbol), but how do I detect if the CPU is 64bit? There is nothing like System.Environment.Is64BitOperatingSystem from the full .NET.
You are allowed to P/Invoke Win32's GetNativeSystemInfo in Windows Store apps (more info on the P/Invoke signature here); it returns a structure that includes the processor architecture.
I can't find any information about what it returns in an x86 Windows on x64 machine scenario, and I don't have such a machine on hand to test it, but it's worth a try.

Sqlite and Windows RT incompatibility issues

I have been working on a two player air hockey kind of game for windows RT devices using monogame, Apart from gaming logic I recently integrated sqlite for winRT in my app so that players could be able to save their scoreboard, view recent scores and share them on social networks. But with this Integration I started running into problems.
before explaining the problem Let me make you aware of my PC and target device architectures.
The machine on which I am developing and testing is Windows 8 pro with 64 bit x64 based processor.
And the target machine is Windows RT 32 bit os, ARM based Processor.
Now when I set the target platform of my app as "ANY CPU" and then try deploying my app I get an error which reads:
Error 1 The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "SQLite.WinRT, Version=3.8.2". Please consider changing the targeted processor architecture of your project (in visual studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM". Pong
Now I set the target platform as ARM then again I am in an error which says
Error 6 Error : DEP0700 : Registration of the app failed. Windows cannot install package da981e37-1c3c-4614-8c85-40485aa9e4a8 because the package requires architecture ARM, but this computer has architecture x64. (0x80073cf3) Pong
then I set the target to x86. This makes the game run normally on my PC but the package installation on target device fails with this option.
Now finally I am left with x64 as the target. This also runs well on my system, also the package gets easily installed on target machine. But it just shows me a black screen for long(Note that it is not a crash!).
I know I might be doing silly somewhere. But I am stuck on this from a long time.
Its a long note, But its only so that I could make you well aware with my problem.
Please provide the answer to the problem.
Your Suggestions are always appreciated :) Thanks.
When you want to Deploy or Debug in your Development machine, set the target Platform as "x86". When you want to deploy or debug in your RT device, change the target platform to "ARM".
You cannot deploy an app which targets "x86", or "x64" to an ARM device.
Also the "Microsoft C++ Runtime Package" dll will not allow you Build with the configuration of "Any CPU".

Develop WPF on Window 7 (32 bit) VMware guest on Mac OS X (64 bit) host

I installed Windows 7 (32 bit) on VMware running on Mac OS X 10.6 (64 bit).
I have VS 2010 on the Windows 7 guest. I developed a WPF C# .NET 4 application using this VS 2010. Will the application be a 32 bit or 64 bit application in this scenario.
32bit. Its your windows machine that is executing the application, and that is 32bit.
.Net applications (and by inclusion WPF applications) are compiled into IL, which is actually converted to machine code by the framework. By default, this IL code is set to be able to run on both CPU types and therefore if your end users are on 64bit machines with 64bit framework, they will get a 64bit application. If 32bit with 32bit framework, they will get a 32bit application.
32bits in this case. It depends on the platform Visual Studio installed on.

C# 32bit project under 64bit windows

I'm working on a form application, I use plenty of hardware, Wiimote, USBjoystick and serial port. It all worked fine under 32bit windows, but I had to upgrade to 64bit for some other apps I'm working on.
I did some research and it is possible to develop x86 apps under x64 system, but now I don't know if this is what I want. The trouble maker is obviously directX sdk. AFAICS another option is, to install a virtual x86 machine specificly for developing this app (I don't want dual boot). I've never used this before, so I'm kinda worried that all this hardware won't work under virtual machine.
I'm using wiimoteLib and blueSoleil to connect bluetooth. So will this work. And do I use windows 7's virtual xp option, or a different virtual machine software? I'd probably use winXP as a virtual OS.
32 bit applications run perfectly fine on 64 bit operating systems. I have lots of my applications developed for 32 bit and they run without any issues in 64 bit. As you say you have lots of hardware used we can't be sure which may work or may not work.
best solution is to run your app in 64 bit and see if anything is not working (I am sure 95% will work) and then come back here with specific questions.
Inside IIS (7) click on Application Pools.
Find the Application Pool that is configured for your web application in the list.
Select it, then click Advanced Settings on the right.
Second setting in the list: Enable 32-Bit Applications - must be set to True.
When compiling your application in Visual Studio, try setting the target platform to x86 rather than "any CPU" (Project options/build/target platform).
I had the same problem running a 32 bit app on a 64 bit development computer. On VS 2010 I had to go to Properties/Configuration Manager/New and choose x86. Then I did a clean and rebuild and it ran fine.

Categories