Click here to Skip to main content
15,881,881 members
Articles / Web Development / ASP.NET

Silverlight Debugging - Beginner's Guide

Rate me:
Please Sign up or sign in to vote.
4.92/5 (9 votes)
22 Dec 2011CPOL3 min read 44K   9   6
Debug or attach the debugger to any local process running a Silverlight-based application in all supported browsers in your system.

Introduction

Sometimes people have difficulties to debug Silverlight applications. Let me give you a hint to make it easy. The key thing is to understand that there are two applications (processes) you might want to debug – server and client. If you typically hit F5 sometimes only server gets debugged. That’s why I do it another way.

How To Start Debugging?

  1. At the beginning, Start Without Debugging:

    1.png

    This will run the server and open the client in your default browser. Because of easier finding of the right process, I close the browser and open client URL in Internet Explorer, since I don’t use it for other tasks (you will see in a minute). You don’t have to start it again as long as the ASP.NET Development Server is running.

  2. Then, before you want to debug your application, you just need to build the solution (in larger applications, rebuilding of the affected project should be enough).
  3. Attach to Process (or press CTRL+ALT+P)

    2.png

  4. If you want to debug server, attach to process called WebDev.WebServer40.EXE (press keys w,e,b and the listbox will find it for you):

    3.png

    If you want to debug client, attach to process of your browser (make sure to choose the process of Type Silverlight!). In my case, it is iexplore.exe:

    4.png

    So, if you want to debug your client app opened in the only Internet Explorer instance running, press: CTRL+ALT+P, i, e, ENTER. Just don’t forget to build the solution and refresh your browser (so that the latest version of client gets loaded).

    1. If you would like to change Default Browser of your Silverlight application, then you may do the following steps:

      5.png

    2. It will open window "Browse With" with list of all installed browsers in your system. You may set any one to your default or favorites browser for this application.

      6.png

      In my case, "Firefox (Default)" was default brwoser, now I like "Internet Explorer". Select Browser from list > click on Set as Default button.

  5. Set a Breakpoint

    In a source window, click a line of executable code where you want to set a breakpoint.

    7.png

    On the Standard Toolbar menu, click on Start Debugging or Press F5 to run the application.

    1. Start or run application

      8.png

    2. Active or Highlight Debugger

      After debugger hits the breakpoint, you may need to execute the code line by line. "Step Over" [ F10 ] command is used to execute the code line by line, when you are debugging inside a method. If you press "Step Into [F11]" within the current method, then the execution will complete the execution of the method and will pause at the next statement from where it called.

      9.png

Summary

This article basically covers fundamentals of debugging in Silverlight application. It describes how to debug an application using Visual Studio.

Comments or Suggestions

If you find some issues or bugs with it, just leave a comment or drop me an email. If you make any notes on this, let me know that too so I don't have to redo any of your hard work.

Please provide a "Vote" if this would be helpful.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen


AWARDS:

  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010


Read More Articles...

Comments and Discussions

 
QuestionVery good article Pin
craig61a26-Jul-12 11:15
craig61a26-Jul-12 11:15 
AnswerRe: Very good article Pin
Sunasara Imdadhusen19-May-13 19:49
professionalSunasara Imdadhusen19-May-13 19:49 
GeneralMy vote of 5 Pin
Savalia Manoj M15-May-12 18:55
Savalia Manoj M15-May-12 18:55 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen19-May-13 19:49
professionalSunasara Imdadhusen19-May-13 19:49 
QuestionExcellent! my vote of 5 Pin
Savalia Manoj M22-Dec-11 22:44
Savalia Manoj M22-Dec-11 22:44 
AnswerRe: Excellent! my vote of 5 Pin
Sunasara Imdadhusen19-May-13 19:49
professionalSunasara Imdadhusen19-May-13 19:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.