Why Visual Studio Debugger is not working for my Silverlight Application?


"Why my Visual Studio debugger is not working for my Silverlight application?" - it's not a new question. People ask this several time in different forums. If you search on net, you may probably find the solution. But, in this post I am just sharing the solution once again for my blog readers and anyone on the net who may face similar issue in future.

 

In this post, I will share you 4 small tips. Just follow the steps from top to bottom and let me know which one resolved your problem. This tip might not be a new thing for you but don't forget to share to others. This could be useful for them.

 

 

One of my blog reader "Raksha" was facing an issue with her Visual Studio debugger. She was not able to find out the way to enable the debugging feature and came to my blog to ask me this question for help:

 

While working with the Silverlight application, I found that it is not following the breakpoints while running the application. Please suggest a way so that I can debug the Silverlight application using the breakpoints.

 

Solution One

There could be some possibilities for that, but let me first tell you that the debugger works in Internet Explorer only. If you are using any browser other than Internet Explorer, you may notice this issue. There are some hacks but I am not interested on that to discuss here. So in such case, just use the IE and that could help you.

 

Solution Two

If you are facing the same issue in Internet Explorer and my friend @debug_mode is still searching the way to debug it Winking smile, you should first check whether the Silverlight debugging is enabled for your Silverlight project. To do this, just follow the below mentioned steps:

  • Right click on the Web Application project that comes with Silverlight project
  • From the context menu, chose "Properties". This will open the properties window in the screen

How to enable the Silverlight debugging

  • As shown in the above screenshot, click the tab named "Web" from the left panel. This will open the web settings window in the right panel
  • Scroll the Window down until you see the "Debuggers" group (as shown above)
  • There the checkbox for "Silverlight" should be checked by default, if not click it to check.
  • Save settings and restart the application in debug mode by pressing F5

Generally this is one of the main reason and people face it due to this option is unchecked.

 

Solution Three

If the above two solutions fails, there could be an issue with your Visual Studio debugger. It may fail to attach the respective process in memory. To resolve this, run the Silverlight application in debug mode and check whether the breakpoint details are loaded in memory. If not, attach the process of the Silverlight application to the IE and this could load the breakpoint now.

 

Solution Four

If you are still facing the same issue after following the above three steps, you may try out a different process which is not recommended though, but sometime that helps. Many time I faced same issue where it was unable to load the debugging information and the above mentioned solutions failed. So, what to do in such scenario? Follow the below steps:

  • First of all, clean the solution from the Visual Studio
  • Close the IDE once you cleaned the solution
  • Go to the solution directory and remove all "bin" and "obj" directories
  • Go to the "ClientBin" folder and remove the .XAP files
  • Open the solution in Visual Studio now
  • Rebuild the solution and hit F5 to start the debugging

This time it will load for sure and if not, try to reset the Visual Studio settings by calling the "devenv /resetsettings" command. Again, the final solution is not recommended unless you failed to resolve this by following the first three steps.

 

Solution Five

As suggested by Paul in the below comments section, you may try out removing the Solution User Options (.suo) file present in your solutions directory.

 

Still have issues?

Drop a line below with your findings. If you have any better solution for that, also share it here. This could help other to resolve it by following your steps. Thank you for reading this tip. Don't forget to share with others.


22 comments

  1. "the debugger works in Internet Explorer only"

    This is not correct. The debugger not only works with all other browsers, but with any process that hosts the Silverlight runtime. The impression that other browsers don't work usually comes from problems of Visual Studio with connecting to the right process (what you describe in "Solution Three"). This is something that happens with IE9 also, by the way. On my system I can reproducibly let debugging with IE9 fail with a freshly started instance of IE. It only works if there already is an IE process that hosts Silverlight.

    To work around those issues more comfortably (than having to e.g. manually search for the correct process and attach to it), I have written a small add-on that does that automatically. At the moment it supports IE9, Firefox (3.6.4+) and Chrome. If you're interested in it, the permanent link to it is:

    http://www.pitorque.de/MisterGoodcat/page/Silverlight-Debug-Helper.aspx

    Cheers,
    -Peter

    ReplyDelete
  2. I've encountered an issue where I can debug in Firefox or Chrome, but it doesn't always refresh the XAP file, so I find I am debugging old code, not my newest changes. I end up having to clear the browser cache after every run, which is annoying, so I end up using IE to debug, which pains me since it's such an awful browser.

    ReplyDelete
  3. Every time I had this problem was a bad compilation. Some how there was an error in RIA Service and did not put the generate code in the silverlight project. The project still running the old generated code and that could now attach.

    The clean solution like you said always resolved my problems


    Paulo Aboim Pinto
    Odivelas - Portugal

    ReplyDelete
  4. I've observed in all of your screenshots used in most of the article having similar type of Annotation markings(i.e. hand & arrow connector). I'm bit curious about which tool you used to create such a wonderful screenshot? Or are you using MS Office & doing it manually?

    TIA.

    ReplyDelete
  5. Thanks for sharing all the solutions Kunal. Much appreciated. 2nd one solved my issue.

    ReplyDelete
  6. it was happened to one of my collaborator: we were using TFS to exchange the source code between us and for some reason the .sln and the .suo files goes out of sync (or at least this is what i tought to be the cause) in any case the debugger doesn't work on this machine but works on mine we both have the same file except for the .suo that is not shared in the project source file.
    so once it have removed the .suo, cleanded and and restared everything, the debugger have started work again. i've not investigated the issue more, so i'm not sure that was the real cause. but give it a try if you run out of other ideas.

    ReplyDelete
  7. if the silverlight application deals with some kind of web service or database call, there is a possibility that the exception occurred at the web service/db query, in case of the problem lies with the web service, use a web debugger such as fiddler2 to debug it. happened to me once, and i almost went crazy because it keeps throwing exceptions that i cant seem to trace.
    sorry if this is completely unrelated, just sharing a personal experience.

    ReplyDelete
  8. My team has this issue frequently. Like Duke mentions above, we suspect the culprit is TFS including/excluding files it shouldn't be. The result is the .pdb file no longer matches with the compiled assy for one or more projects.

    Things we do to get working again:
    1. Clean Solution -try debug again
    2. remove assy and pdb's in the build folder then delete the solution user options (.suo) file. The breakpoint definitions are maintained in .suo -try debug again
    3. Under Project Properties of the affected proj, go to Build, Advanced button and change Debug Info to pdb-only, save it then go back and flip it back to full and save again. -try debug again
    4. manually clean your solution by closing VS and removing the following folders:
    - Bin
    - Obj
    - ClientBin on the website proj
    try debug again

    ReplyDelete
  9. Thanks...Very Much!!

    ReplyDelete
  10. Thanks for sharing all the solutions it helps me lot

    ReplyDelete
  11. In my case, I had Silverlight 5 library project with RIA services. VS 2010 with SP1 stopped responding recently while debugging. I tried most of the suggestions mentioned here, but nothing seemed to work. Finally, I deleted the hidden solution user options (.suo) file as mentioned here by Paul and after that things came to normal. Thank you all.

    ReplyDelete
  12. Hi
    I am Suraj Harale
    I have issue in debugging Silverlight4 project in asp.net
    I used Silverlight project as user control in my web application I unable to debug Silverlight project and test Business logic written in that project
    I followed your steps but still i have issue

    Please help me
    Thanks

    ReplyDelete
  13. Thanks, second solution resolved my issue.

    ReplyDelete
    Replies
    1. Glad to know that it solved the problem that you were facing.

      Delete
  14. I followed the second solution.

    Thank you very much kunal.

    ReplyDelete
  15. After Running the Silverlight application in any browser, just select "Attach to Process" from Debug menu. Then select "plugin-container.exe" from the list shown. Then Click attach button. This should set the browser in debug mode.

    ReplyDelete
  16. I am facing a strange problem where my Silverlight application hits the breakpoint on debugging, but as soon as I press any function key to debug the application, it exits the application.
    In short I am able to hit my first breakpoint but any action to debug or continue exits my application. Also this happens only for my Silverlight application, other C# applications work fine.

    ReplyDelete
  17. Remove all files and folders inside

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

    and

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

    then try debugging

    ReplyDelete
  18. HI,
    Thanks for your post. But when I try to attach to process Iam getting an error -

    Unable to attach to the process. The 32-bit version of the Visual Studio Remote Debugging Monitor (MSVSMON.EXE) cannot be used to debug 64-bit processes or 64-bit dumps. Please use the 64-bit version instead.

    I ran the 64 bit MSVSMON.exe from ‘C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Remote Debugger\x64′ folder. And now my Task manager is also showing Visual Studio Remote Debugging Monitor from the X64 folder. But still Iam not able to debug my silver light.

    Can you please help me with some suggestions ? It will be agreat help..

    Thanks
    Regards
    Nimisha

    ReplyDelete


 
© 2008-2014 Kunal-Chowdhury.com | Designed by Kunal Chowdhury
Back to top