How to debug Silverlight application with only XAP file?

Sometime, when the application is deployed to IIS server you may still need to do some debugging. Debugging a Silverlight application is in fact very easy, and pretty much the same when you are working inside Visual Studio but change when you need to debug it on the server.

The first step is to be sure that you .xap file deployed on IIS is the same as the one that you have in your developer environment. This can be automated when a Post-Build condition like this:

copy $(TargetDir)YOURxapFILEname.xap c:\wwwroot\mywebsite\ClientBin\YOURxapFILEname.xap

The second step is to go in Debug menu of Visual Studio and choose Attach To Process. This is a step that you would have to do to debug ASP pages. But, this will require a modification. When debugging .Net code, you usually set your debugging type to Managed. In the case of Silverlight, you must select Silverlight. This will automatically popup you a message saying that you cannot continue to debug in Managed. Just accept.

The debugging type must be Silverlight

The third step is to attach to the process. This also require a modification. When debugging a ASP page you usually select W3WP.exe (the IIS application pool). This time, you need to attack to your browser. This can be Internet Explorer, Firefox or Chrome. The reason is that Silverlight is not server side but client side.

You must attach to the browser, not IIS

From there you just need to refresh your page and the breakpoint you have set will be trig once reached.

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

2 thoughts on “How to debug Silverlight application with only XAP file?

  1. Most of you will know that a Silverlight application runs in the Browser and Console.WriteLine() doesn’t work.

    During the development process you could use System.Diagnostics.Debug.WriteLine() to write messages to Visual Studio’s Output window.

    But what if an application is deployed and no Visual Studio is nearby and you just want simple Console output and not a logging framework like Clog, where a web service is involved? Or don’t want to use Visual Studio’s Output window?

    • Hello kiquenete,
      I have to say that this post is old (about 5 years old) and Silverlight is dead which mean that I am not into it anymore. I suggest that you try to output somewhere else than using console.log or use Visual Studio (it’s free).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.