Debugging apps for Windows Phone 8
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
This topic contains the following sections.
- Debugging Windows Phone projects
- Disabling the screen lock for debugging
- Supported debugging features
- Debugging XNA Framework projects
- Related Topics
Debugging Windows Phone projects
You can debug Windows Phone projects the same way that you debug any other project type. When you press F5, Visual Studio starts the app in either Windows Phone Emulator or a Windows Phone device and starts the debugger at the same time. You can then perform common tasks, such as setting breakpoints and examining the call stack. For information about deploying apps to the device or emulator, see How to build an app for Windows Phone 8.
You can debug an app that targets Windows Phone 8 when it's launched from a Tile or a push notification, not only when it's launched directly. When you launch your app with debugging on Windows Phone 8 Emulator or on a Windows Phone 8 device, click the Back button to exit the app; the debugger remains attached. After you launch the app again by using the Tile or the push notification, you can continue to debug the app.
You can choose whether to debug the managed code or the native code portion of your app in the Debugger Type section of the Debug page in Project Designer. If your app communicates with a background agent, you can also choose whether to debug the managed code or the native code portion of the background agent independently. You can debug both the app and the background agent in the same debugging session. However you cannot debug both the managed code and the native code portions of your app, or both the managed code and the native code portions of your background agent, at the same time.
For general information about debugging with Visual Studio, see Debugging in Visual Studio.
Disabling the screen lock for debugging
To avoid screen locks while debugging your app, include the following code in your app. Later, remove this code to test the app’s behavior when the lock screen engages.
// Avoid screen locks while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
' Avoid screen locks while debugging.
If System.Diagnostics.Debugger.IsAttached Then
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled
End If
Supported debugging features
The following table shows the debugging features supported in Visual Studio Express 2012 for Windows Phone and Windows Phone Add-in for Visual Studio 2012.
Feature |
Windows Phone Add-in for Visual Studio 2012 |
Visual Studio Express 2012 for Windows Phone |
Notes |
---|---|---|---|
Managed debugging |
Yes |
Yes |
Debugging of XAML and XNA Framework projects for Windows Phone is supported. |
Attach to local process |
No |
No |
This command is present only in theWindows Phone Add-in for Visual Studio 2012. When you try to attach to a local process with the add-in, a message will indicate that you cannot connect to the specified device. |
Attach to remote process |
No |
No |
|
Breakpoints:
|
Yes |
Yes |
|
Breakpoints:
|
Yes |
Yes |
|
Breakpoints:
|
No |
No |
|
Breakpoints:
|
Native debugging only |
Native debugging only |
|
Cross-machine debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. Not relevant on Windows Phone–based apps. |
Cross-thread debugging |
Yes |
No |
This refers to switching to another thread while debugging. |
DataTips |
Yes |
Yes |
|
Debugger windows:
|
Yes |
Yes |
|
Debugger windows:
|
Yes |
No |
This feature is not supported in other Visual Studio Express Editions. |
Debugger windows:
|
Native debugging only |
Native debugging only |
|
Debugging in a security zone |
No |
No |
This feature is relevant only for Internet Explorer. |
Design-time expression evaluation |
No |
No |
For example, a function you type in the Immediate Window at design time will not evaluate. |
Detach all |
No |
No |
The Detach all command behaves the same as the Terminate all command; the process is terminated along with the debugging session. This command is not present in any Visual Studio Express versions. |
Edit and Continue |
No |
No |
Code editing is blocked during debugging sessions. |
Exception Assistant |
Yes |
No |
|
Exception handling configuration |
Native debugging only |
No |
Windows Phone projects always break at unhandled exceptions. You can select Exceptions from the DEBUG menu and change these settings, but changes have no effect. This command is present only in the Windows Phone Add-in for Visual Studio 2012. |
Expert Settings |
Yes |
Yes |
|
IntelliTrace |
No |
No |
This feature is not supported in other Visual Studio Express Editions. Configuration of historical debugging is not available. |
Interop debugging |
No |
No |
Interop is not supported on Windows Phone. |
Just-in-time debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
Just My Code (JMC) debugging |
No |
No |
|
Manually setting a debugging engine |
Yes |
Yes |
For a hybrid app, such as a Direct3D XAML application, you can choose Managed Only or Native Only debugging for both the UI task and any agent tasks. For a managed app, the debugging engine is Managed Only and cannot be changed. |
Minidump support |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
MPI Cluster debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
Multiple process debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
Native debugging |
Yes |
Yes |
|
NTSD extension support |
No |
No |
This feature is not supported in other Visual Studio Express Editions. Native debugging is not supported. |
Remote debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
Run to cursor |
Yes |
Yes |
This feature is not supported in other Visual Studio Express Editions. With the Windows Phone Add-in for Visual Studio 2012, you can access this feature by using the shortcut menu in the Code Editor or the Call Stack window. |
Script debugging |
No |
No |
JScript is not supported. |
Simplified debugging UI |
Yes |
No |
This feature is not supported in other Visual Studio Express Editions. |
Source service |
No |
No |
This feature is not supported in other Visual Studio Express Editions. This function is handled automatically. |
Step through code (Step Into, Step Over) |
Yes |
Yes |
|
Switch to Frame (call stack rewind) |
Yes |
Yes |
|
Symbol server |
No |
No |
Symbols are not available when you are debugging Windows Phone components. |
Tracepoints |
No |
No |
|
Transact-SQL and SQL Server CLR integration debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. This feature is not supported with the Windows Phone Add-in for Visual Studio 2012, but it is not blocked. |
XSLT debugging |
No |
No |
This feature is not supported in other Visual Studio Express Editions. |
Debugging XNA Framework projects
You can debug XNA Framework projects that target Windows Phone OS 7.1 in the same way that you debug other apps for Windows Phone. For information about supported and unsupported debugging features for XNA Framework projects, see Debugging a Windows Phone Game.
Note
To debug an app that renders XNA content in the emulator, the computer on which you’re debugging the app must be GPU-enabled.