Click here to Skip to main content
Click here to Skip to main content

Silverlight Debugging - Beginner's Guide

By , 22 Dec 2011
 

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)

About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Member
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. 1st Best Asp.Net article of SEP 2010
  2. 2nd Best Asp.Net article of MAY 2011
 
Read More Articles...

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionVery good articlemembercraig61a26 Jul '12 - 11:15 
Thanks!
AnswerRe: Very good articleprofessionalSunasara Imdadhusen19 May '13 - 19:49 
Thank you very much

sunaSaRa Imdadhusen
+91 99095 44184

GeneralMy vote of 5memberSavalia_Manoj15 May '12 - 18:55 
Good solution...
GeneralRe: My vote of 5professionalSunasara Imdadhusen19 May '13 - 19:49 
Thanks a lot dear

sunaSaRa Imdadhusen
+91 99095 44184

QuestionExcellent! my vote of 5memberSavalia_Manoj22 Dec '11 - 22:44 
Great article and with help of that i am able to debug.
 
Thanks for sharing with us!Thumbs Up | :thumbsup:
AnswerRe: Excellent! my vote of 5professionalSunasara Imdadhusen19 May '13 - 19:49 
Thank you very much for your appreciationsRose | [Rose]

sunaSaRa Imdadhusen
+91 99095 44184

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 Dec 2011
Article Copyright 2011 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid