IT tutorials
 
Mobile
 

Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 2) - Debugging in the Emulator, Debugging with a Device

12/15/2012 6:00:36 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Debugging in the Emulator

If clicking the user interface was not working the way we would like, it might help if we could stop the operation during an event to see what was happening during execution. We can do this by debugging our operation. We can use the debugger to set breakpoints and break in code while using the emulator. Place the text cursor inside the event handler and press F9 to create a breakpoint. When you run the application (again, press F5) you can see that when you click on the theStatus TextBlock the debugger stops inside the event handler. You can hover your mouse over specific code elements (e.g., theStatus.Text) to see the value in a pop up (as shown in Figure 3).

Figure 3. Using the Visual Studio debugger

Image

Pressing the F5 key while stopped at a breakpoint will cause the application to continue running. There are other ways to walk through the code, but for now that should be sufficient to get you started. Using the emulator is the most common way you will develop your applications, but there are some interactions that are difficult to do with the emulator (e.g., multitouch, using phone sensors, etc.) for which debugging directly on a device would be very useful. Luckily, debugging on the device is supported and works pretty easily.

Debugging with a Device

If you have a phone with which you want to do your development, you will want to be able to deploy and debug directly on the phone itself. First you need to connect your phone to your development machine. All you need to do is connect your phone to your computer by a USB cable.

Now that your device is connected, you can use it to browse to the directories for music, photos (etc.). However, before you can use a phone as a development device, you will need to register the phone for development. This lifts the requirements that applications be signed by Microsoft, and allows you to deploy your applications directly to the phone so that you can debug applications.

Before you can enable your phone as a developer phone, you will need to have an account at the Windows Phone developer portal (http://developer.windowsphone.com). Once you have done that, you can enable your phone to be used for development. To do this you will need the Windows Phone Developer Registration tool, which is installed when you install the Windows Phone SDK. When you run this application it will detect the device. You will need to make sure the device is unlocked and turned on. At that point the Windows Phone Developer Registration Tool will enable the “Register” button as shown In Figure 4.

Figure 4. Windows Phone Developer Registration Tool

Image

Next it will ask you for your Windows Live ID that you used to register with the developer portal, as shown in Figure 5.

Figure 5. Signing into with your Microsoft ID

Image

If your phone is successfully attached to your computer, the Status area will tell you that it is ready to register your device for development. At this point, just click the Register button to register with the developer portal. Once it registers the phone, it changes the status to show you that the phone is ready.

When you use a device to debug, you will find it much easier to change the default time-out of the device to be longer than the default (usually 1 minute, but it depends on the device manufacturer and carrier). To do this go to the settings on your phone. In the settings, there is an option called “lock screen” as shown In Figure 6.

Figure 6. “lock screen” option on the settings screen

Image

Once in this option, you can scroll down to find the “Screen times out after” option and open the option and pick the longest timeout you can tolerate (this will affect battery life when you’re not debugging on the device, so be careful to pick a time out you can live with if it’s not a testing-only device). You can see this in Figure 7.

Figure 7. Changing the default device timeout

Image

Now that you’ve registered your device, you can deploy and debug your applications using Visual Studio. The key to using the device instead of the emulator is to change the deployment using the drop-down list of deployment options. The drop down is located in the toolbar of Visual Studio, as shown in Figure 8.

Figure 8. Changing the deployment to use a development phone

Image

Once you change the deployment target you can debug just like you did with the emulator. When you run the application, it will deploy your application to the device and run it so that you can debug it in the same way as you did with the emulator.

 
Others
 
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 1) - Working with Events
- Windows Phone 8 : Designing with Blend
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 2) - Implementing the Location Manager Delegate
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 1)
- Iphone Application : Implementing Location Services - Understanding Core Location
- Windows Phone 8 : Creating a New Project (part 2) - XAML
- Windows Phone 8 : Creating a New Project (part 1) - Visual Studio
- Developing BlackBerry Tablet Applications : Permissions and Configuration Settings
- Developing BlackBerry Tablet Applications : Permissions
- Introducing Windows Phone 8 : The Marketplace
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us