How do I debug my Silverlight 4 application?

2020-07-24 04:55发布

问题:

I cannot figure out how to get my breakpoints to take in my silverlight application. I've tried setting up a test page, but nothing seems to work.

Here are some of the things I've tried:

Enable Silverlight Debugging: In my Web project, I've set the 'Web' => 'Debuggers' => 'Silverlight' to checked.

Attach to Process: I'm using Chrome, but the page I need to attach my debugger to is disabled in my 'Attach to Process' window.

Using Firefox: I followed Tim Heuer's post where he describes turning off npctrl in the about:config page.

I've tried many other things as well over the last few hours, but nothing is working. I fear that I'm missing something.

UPDATE: October 20, 2011

Fixed the problem and posted my answer below.

回答1:

Fixed! I fixed the problem by removing all auto generated files (*.user, *.suo, /bin, and /obj). What a nightmare of a bug this has been. Here was everything I checked:

  1. Ensured my ASP.NET MVC application had 'Silverlight Debugging' checked. Did this by navigating to my Web project's Property Page => Web Tab => {Scroll to bottom} => Check 'Silverlight'

  2. Set my default browser to Internet Explorer. Did this by right clicking on my TestPage.aspx in my web project => Browse with... => Internet Explorer (not sure if this was needed but I did do this, so..)

  3. Cleared my Web Cache from Internet Explorer. Did this by opening IE => [Tools => Options...] => [General Tab] => [Browsing History Group] => Delete History button!

  4. Removed all my auto-generated files from Visual Studio. Did this by manually finding all *.csproj.user files, *.suo file, and all "/obj" and "/bin" folders.

  5. Cross my fingers! (Important step!)

  6. Open my project... set a break point in my Silverlight code... clicked Run!

To my surprise it all began working. I rejoiced. :) Ultimately it was due to my auto generated files, because I did the first 5 steps over and over and over, to no avail. I do believe that each step played a key role in getting me to debug my application again, but the last step was the kicker for me.

At one point during this "adventure", I went so far as to reinstall VS2010, VS2010 SP1, Resharper 6, Silverlight 4 Developer Tools, etc, etc... Basically, my full dev environment. This was because I thought I had an invalid version of Silverlight 4 on my machine. Upon trying to "Repair" the Silverlight 4 Developer Tools, the install told me that Visual Studio 2010 wasn't properly installed... hence the derailing path... Ugh!! Many hours were lost trying to debug my Silverlight application. However, all is good with the world now.

I hope my post helps somebody!