Windows 8 simplifies the process of building apps that target different devices. Windows Phone 8 takes advantage of many of the features introduced with Windows 8, but it is a different platform with different requirements. Thus, if you want to create apps for both Windows 8 and Windows Phone 8, the initial release of Visual Studio 2012 won't be enough and you will have to install an additional SDK and pay special attention to the requirement to run the Windows Phone 8 emulator. In this first article in a three-part series dedicated to developing Windows Phone 8 apps, I explain everything you need to know to start developing Windows Phone 8 apps in Visual Studio 2012.
Visual Studio 2012 enables developers to create apps that target Windows 8. However, because Microsoft launched Windows Phone 8 after Windows 8, and so, if you want to start developing apps for Windows Phone 8 with your existing Visual Studio 2012 installation, you need to download and install the latest Windows Phone SDK.
If you don't have Visual Studio 2012 installed, the Windows Phone SDK 8.0 will install Visual Studio Express 2012 for Windows Phone. However, if you have Visual Studio 2012 Professional, Premium, or Ultimate, the Windows Phone SDK 8.0 installs an add-in that provides your existing IDE with all the necessary features to create, deploy, and test Windows Phone 8.0 apps. The SDK 8.0 also targets Windows Phone 7.x, but I won't focus on previous versions in this article.
The Windows Phone SDK 8.0 includes the following components:
- Visual Studio 2012 Express for Windows Phone.
- Microsoft Blend 2012 Express for Windows Phone. If you have a full version of Blend 2012 installed, the installation will add Windows Phone 8.0 capabilities to it.
- Windows Phone 8.0 device emulator.
- All the necessary reference assemblies for managed code development.
- All the necessary headers and libraries for native code development.
- Project templates for both managed code and native code development.
You need a 64-bit version of Windows 8 to install and run the Windows Phone SDK 8.0. However, the Windows Phone 8 Emulator runs only on Windows 8 Pro edition or greater. So, if you want to develop without limitations, you need at least Windows 8 64-bit Pro edition. Windows Phone 8 Emulator runs on top of Hyper-V, and therefore, it requires a 64-bit CPU that supports SLAT (short for Second Level Address Translation). Windows Phone 8 emulator is different from the previous Windows Phone emulators, and so you should check whether your CPU supports SLAT even if you are using your computer to develop apps for previous Windows Phone versions. If your CPU doesn't support SLAT, you will be able to develop Windows Phone 8 apps, but you will have to deploy and test them on a physical Windows Phone 8 device because the emulator won't run.
Many modern 64-bit multicore CPUs from both Intel and AMD include SLAT but many older CPUs that are capable of running Windows 8 64-bit and Visual Studio 2012 with excellent performance don't support SLAT. Intel and AMD use the following two different names for the memory virtualization technology known as SLAT:
- EPT (short for Extended Page Tables) identifies SLAT support for Intel CPUs
- NP (short for Nested Page Tables) identifies SLAT support for AMD CPUs
A hypervisor such as Hyper-V must manage the virtual memory of the different guest operating systems and translate it into host physical pages. This task can be extremely CPU-intensive without the appropriate help of hardware support for nested paging caches. SLAT simplifies the work required by the hypervisor to translate memory addresses and directly handle page faults. This way, SLAT reduces one of the major sources of virtualization overhead, and thereby improves overall performance of guest operating systems. That's why Windows Phone 8 emulator runs on top of Hyper-V with SLAT.
The latest versions of Microsoft's CoreInfo utility allow you to determine whether your CPU has the necessary requirements to execute the Windows Phone 8 emulator. You can download it (CoreInfo 3.2). By default, when you run the coreinfo.exe at the command-line, the utility runs with all the options enabled, except virtualization features.In this situation, you are specifically interested in virutalization support, so run it wit the
-v option, which will show SLAT support. It is not necessary to install CoreInfo, and therefore, you can use it by just running the executable file and accepting the license. You just need to accept the license once. The
-v option requires administrative rights on Intel systems, so it is wise to run CoreInfo with administrative rights if you have doubts about your underlying hardware.
If you're still mastering the changes that Windows 8 introduced with the removal of the Start menu and you haven't install Windows 8.1 preview, you'll benefit from a simple shortcut to run a command prompt with administrative rights: Just press Windows + X and select Command Prompt (Admin) in the context menu that appears. This Windows + X shortcut saved me a lot of aggrivation when I started working with the pre-release versions of Windows 8 and I needed to use the command prompt and the other options that the context menu offers. Windows + X brings up a menu with many useful system options that previous Windows versions provided in the Start menu (see Figure 1).
Figure 1: The context menu that Windows 8 displays when you press Windows + X.
Once you open a command prompt with administrative rights, go to the folder where you saved the downloaded CoreInfo executable file and run CoreInfo
-v. If your computer already has Hyper-V activated, you will notice CoreInfo displays a note indicating that you must execute it without a hypervisor running for accurate results and an asterisk will appear on the right-hand side of the HYPERVISOR row indicating that your computer supports SLAT. If that's the case, don't worry about the dashes that you will see for the virtualization-related technologies such as VMX and EPT for Intel CPUs, or SVM and NP for AMD CPUs. They indicate that your CPU doesn't provide the features, but you already have Hyper-V activated and the asterisk for HYPERVISOR means that you will be able to execute the Windows Phone 8 emulator. The following lines show an example of the results for an Intel CPU when Hyper-V is already activated:
C:\Gaston>coreinfo -v Coreinfo v3.2 - Dump information on system CPU and memory topology Copyright (C) 2008-2012 Mark Russinovich Sysinternals - www.sysinternals.com Note: Coreinfo must be executed on a system without a hypervisor running for accurate results. Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz Intel64 Family 6 Model 30 Stepping 5, GenuineIntel HYPERVISOR * Hypervisor is present VMX - Supports Intel hardware-assisted virtualization EPT - Supports Intel extended page tables (SLAT) M/
If you don't have Hyper-V activated and you execute CoreInfo
-v on a computer powered by an Intel CPU, you should see an asterisk on the right-hand of EPT. The following lines show an example of an Intel CPU with SLAT support when Hyper-V isn't yet activated (notice the on at the right-hand side of HYPERVISOR):
C:\Gaston>coreinfo -v Coreinfo v3.2 - Dump information on system CPU and memory topology Copyright (C) 2008-2012 Mark Russinovich Sysinternals - www.sysinternals.com Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz Intel64 Family 6 Model 30 Stepping 5, GenuineIntel HYPERVISOR - Hypervisor is present VMX * Supports Intel hardware-assisted virtualization EPT * Supports Intel extended page tables (SLAT)
If you don't have Hyper-V activated and you execute CoreInfo -
v on a computer powered by an AMD CPU, you should see an asterisk at the right-hand of NP. The following lines show an example of an AMD CPU with SLAT support when Hyper-V isn't yet activated:
C:\Gaston>coreinfo -v Coreinfo v3.2 - Dump information on system CPU and memory topology Copyright (C) 2008-2012 Mark Russinovich Sysinternals - www.sysinternals.com AMD Phenom(tm) II X4 955 Processor x86 Family 16 Model 4 Stepping 3, AuthenticAMD HYPERVISOR - Hypervisor is present SVM * Supports AMD hardware-assisted virtualization NP * Supports AMD nested page tables (SLAT)
If you want to dive deeper into CoreInfo, consult this short article.
Preparing the Development Environment
Once you have checked whether your CPU provides SLAT support, it is time to install the Windows Phone SDK 8.0:
- Download the Windows Phone SDK 8.0. If you're OK with the English version, just click on the Download button below SDK 8.0 (Figure 2), and you will get the WPexpress_full.exe file (1 MB). Make sure you don't click on the Download button for the previous versions because they are all listed on the same page. In case you want to download Windows Phone SDK 8.0 in a different language, you can select the desired download from the available languages here.
Figure 2: The main page for Windows Phone Dev Center provides the download links for all the versions of Windows Phone SDK.
- Launch WPexpress_full.exe and the first dialog box of the Windows Phone SDK 8.0 installation will appear (Figure 3). You can read the complete license terms and conditions by clicking on License Terms. Then, activate the license acceptance checkbox and click INSTALL. Click Yes when Windows User Account Control (UAC) asks you for permission to continue. Take into account that the Windows Phone SDK 8.0 installation might disable/enable networks during setup. In addition, if you haven't activated Hyper-V on Windows 8, you will need to restart your computer during the installation process.
Figure 3: Windows Phone SDK 8.0 installation displaying the disk space requirements and the license terms acceptance checkbox.
- Windows Phone SDK 8.0 installation will start downloading and installing all the necessary elements. Once the installation finishes the Hyper-V configuration for the Windows Phone 8 emulator, it might be necessary to restart the computer before setup can continue (Figure 4).
Figure 4: Windows Phone SDK 8.0 installation needs to restart the computer after it configures Hyper-V.
- When Windows Phone SDK 8.0 finishes the installation, you will be able to launch Visual Studio 2012 and start developing apps that target Windows Phone 8, as well as use the emulator to check how apps behave.