views:

241

answers:

5

I used to be able to attach to my w3wp process and Debug my web application, but this is not working anymore. I have no idea what changed to break this. I'm using Visual Studio 2008 SP1. And I'm debugging in IIS, not using ASP.NET's own server (i.e. I don't Run my project, I simply attach to a running process (w3wp).

My breakpoints simply have the "breakpoint will currently not be hit. The source code is different from the original version."

What I have tried:

  • Did a solution Clean.
  • Did a solution Rebuild.
  • Made sure that compilation debug=true in my web.config file.
  • Deleted the bin folder
  • Restarted Visual Studio
  • Restarted IIS
  • Restarted my Computer
  • Added a simple Response.Write to ensure that the latest DLL is being used. It is.
  • Made sure that Debug ASP.NET is checked in my project properties. It is.
  • Made sure that all my projects are compiled in my build configuration. They are.

But none of these help. I attach to w3wp, but my breakpoints never get hit.

Any ideas?

+1  A: 

in the "Attach to process" dialog, click the checkbox (near the bottom) for "show processes from all users" and if you see two w3wp.exe processes, try the other one.

One should have a comments/description value of something like T-SQL, managed somethingoranother. This is the one you want.

David
Good tip. But I only have one w3wp (all my checkboxes are checked). And it's Type is "T-SQL, Managed, x86".
willem
That's a hack, not a fix. Something's wrong with his setup.
Will
+4  A: 

I had this problem recently and I ended up first making sure Visual Studio was not running at all on the system.

Then went into this folder and deleted all its content:

C:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
Gautam
No luck I'm afraid :(
willem
+3  A: 

Check your web.config for

<compilation debug="true">...
citronas
Good tip. But it is :(
willem
+1  A: 

Are you running any add ins that could be affecting this? Or any tools that apply post build operations to the source code that the DLLs you start debugging with have been modified post build and it actually is correct that it's not the same source code so debugging won't work?

Also have tried resetting VS?

devenv.exe /resetsettings

Edit: if none of the information has aided you here, while painful it might be worth uninstalling and reinstalling VS and SP1. If you go through this and the issue is the same afterwards that atleast assures that the issue lies in either the web.config or the project settings.

Chris Marisic
No luck unfortunately :(
willem
Add another suggestion
Chris Marisic
+1  A: 

When you "Attach to process", the Output window should show you (when showing output from "Debug") all the libraries it's loading, and where it's loading them from - for the dll's in your /bin folder these are usually copied to the \Temporary ASP.NET Files\root\ folder - where are yours being read from? Have you definitely cleared them out from there?

The only other things I can think of:

  1. You've compiled your code in "Release" mode rather than "Debug" (not the web.config) from the Solution Configuration drop-down.
  2. The symbol files (.pdb) are missing from your /bin folder.

On the "Build" tab of the project properties, you are in configuration "Active (Debug)", you haven't check "optimize code"?

If you click "Advanced..." on that tab, what value do you have for "Debug Info"? Is it "full" or "none"?

Responding to comment

You will find it harder to debug successfully if your code compiled in "Release" mode, and you'll often get the "source code is different" message when you've not rebuilt the symbols (.pdb files) after changes - but you say you've done a clean/rebuild, so that should cover that.

Yes, your output window will show all the framework dlls that you're referencing as well as your code - but you should see one file listed in there with the name of each project output - those are the ones to look at.

You don't have some post build event that moves files into the correct directory for your site do you that's silently failing?

Zhaph - Ben Duguid
Thanks, definitely some good things to consider :) I have compiled my code in Release mode. My symbol files are in my \bin folder. "Optimize Code" is Not checked. Debug Info is "Full". The only remaining confusing thing is which files are supposed to show up in my "Debug Output" window. Lots of files there :/
willem
Nope, no post build events. I'm really stumped :/
willem
Are you able to debug successfully when you compile in "Debug" mode?
Zhaph - Ben Duguid
Nope, I am in Debug mode already.
willem
Ok, only your original comment said "I have compiled my code in Release mode".
Zhaph - Ben Duguid