Debugging Windows Phone 7 Applications

Must Read

Just post!

If you are working in Visual Studio or Visual Studio Express, you can use the standard debugging tools to break, step through, and profile a Windows Phone 7 application. You can also view variable values and the execution tree and processes.

A Windows Phone 7 application uses Silverlight and Windows Presentation Foundation (WPF) to define the interfaces, so any debugging techniques you use in Silverlight and WPF also apply to Windows Phone 7. For example, there are some specific issues related to WPF styling and data binding that can arise in an application. These include the following:

  • Errors in the auto-generated partial class for a XAML component that prevent the component from being available to code in the page or the application. In most cases, you can  resolve this by right-clicking the XAML file in Solution Explorer and then clicking Run Custom Tool to regenerate the partialclass.
  • Errors in the XAML style definitions for components. These may occur in the App.xaml file or in other files within your application. Typically, the exception message indicates only that a COM component error has occurred and provides an HRESULT value. The simplest approach to resolving these types of errors are to minimize the surface area by temporarily removing some or all of the XAML styling definitions until the error disappears, and then reading them one by one to locate the faulty definition.
  • Data binding errors, such as using the wrong property name in a binding statement. This does not generate a run-time error, but the control property (such as the text) is not set. You can see a list of data binding errors in the Output window of Visual Studio or Visual Studio Express as the application executes. For example, you will see the following message if you specify binding to a property named City that does not exist in the data context.System.Windows.Data Error: BindingExpression path error:
    ‘City’ property not found on [your data context component
    name]. BindingExpression: Path=’City’ DataItem=’[your
    data context item]’; target element is ‘System.Windows.
    Controls.TextBlock’ (Name=’ItemText’); target property
    is ‘Text’ (type ‘System.String’).


  • Remote service access errors. If your application cannot retrieve data from a remote service, try copying the URL of the service from your code into a web browser to see if it is accessible. You can also download and install a web debugging proxy utility such as Fiddler or a similar utility to view all the HTTP(S) traffic between your application and the service. Fiddler is available from the Fiddler website (

One specific point to note when debugging Windows Phone 7 applications using the emulator is that certain actions within the phone may halt the debugger. For example, if the code opens a task or the launcher, or if it is tombstoned, execution may not continue automatically after the interruption. To continue debugging, press F5 in Visual Studio within 10 seconds of the task completing or the applications being reactivated.


- Advertisement -

Latest News

Revolutionizing Green Logistics: NX Logistics Thailand Rolls Out Its Premier Electric Truck

NX Logistics Thailand, a subsidiary of the global NIPPON EXPRESS HOLDINGS, INC., marks a significant stride in eco-friendly transportation...
- Advertisement -

More Articles Like This

- Advertisement -