6

I have a web application that I've always been able to run in Visual Studio and it debugs just fine (breakpoints work, I can pause execution, etc). Recently, the behavior changed suddenly, and a few things happen:

  • I start debugging, it lauches IE and loads the application, but after a few seconds (sometimes the page hasn't even displayed yet), Visual Studio acts as if debugging has stopped - I'm able to edit code in VS again, and the "Play" button on the toolbar is enabled. The application continues to run in the IE window just spawned, but I'm not attached to it
  • During this few seconds that VS is "debugging", because it detaches, my breakpoints show as hollow - as if I'm set to "Release" mode and they won't be hit. In fact, I have a breakpoint set in Page_Load, and it skips right by. I've checked, and I'm set to debug mode, though the compile mode dropdown is missing from my toolbar (I checked in the build properties to ensure I was in debug mode).

Can anybody shed some light here?

Sharun
  • 3,022
  • 6
  • 30
  • 59
SqlRyan
  • 33,116
  • 33
  • 114
  • 199
  • I'm having the same issue with a WAP (Web Application Project, not "Web Site") in VS 2005 on WinXP. I have one system.web in Web.config. I am an admin on my machine, so I'm always running everything that I open as an administrator, right? This has come up intermittently on various projects, but unfortunately, I was not careful to record variables connected to the project (shame on me!). – jyoungdev Jun 07 '10 at 16:35
  • 1
    @apollodude217: If you're using Vista or 7, then there's a difference between having local admin rights and "running something as an administrator". If you right click on a link and select "Run as administrator", that's what I'm referring to here as the solution to this problem - simply being a local administrator on your computer isn't enough, because of Vista's UAC. – SqlRyan Jun 07 '10 at 20:40
  • This is very similar to this question: http://stackoverflow.com/questions/9374530/debugging-doesnt-start/16888157#16888157 – GlennG Jul 18 '13 at 15:30

7 Answers7

11

It turns out that this was actually a result of an upgrade to Windows Vista. VS wasn't being "Run as an Administrator", which caused it to lack the rights to attach to other processes for debugging. As a result, debugging would stop right after it started. Changing the VS shortcut to run as an administrator resolved this problem.

SqlRyan
  • 33,116
  • 33
  • 114
  • 199
  • Good to know. I'd vote it up, but I'm not registered (waiting for MS Live Messenger to support OpenID). So apparently it's not specific to web-apps. You might edit "web" out of the question, but it's probably fine to leave it. But, it might be good to add "vista" as a tag, to help others find this. – Rob Parker Feb 10 '09 at 16:13
  • I've modified the tags. The first thing I go on my installations is disable UAC, so I didn't even consider that this might be a problem on somebody else's computer. I'll remember to check it in the future. – SqlRyan Feb 10 '09 at 16:16
  • Sorry, I was unclear; I just meant take the word "web" out of the question title. I think it's fine to be specific about your case in the body, but the title suggests it's specific to web apps, which might put someone off reading the body to see the general answer. Now it's a little confusing. ;) – Rob Parker Feb 10 '09 at 16:36
  • Doing my bit for least privilege: VS can debug fine on Vista w/o admin privileges -- as long as the process to be debugged is running under the same account. – Roger Lipscombe Nov 13 '09 at 16:55
  • Faced the same issue when upgraded to Windows 8.1. And this solution worked – Sharun Oct 22 '14 at 14:34
2

I've experienced samely looking behavior. The cause was in existence of several <system.web> sections (which is allowed by web.config schema). Visual Studio debugger (versions 2008 and 2010 were tested) looks in the first encountered section only. So if your <compilation debug="true"> tag is not in the first one, it thinks that there are no compilation.debug setting present and genrally tryes to add <compilation debug="true"> to the first <system.web>. In some cases VS2008 just silently procceds in this case. For example look here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=510354#details"

Konstantin Salavatov
  • 4,370
  • 2
  • 25
  • 24
0

Quick windows 7 update: I had to add "localhost" to my list of trusted sites to correct this issue...go figure.

jesse
  • 1
0

Just a workaround for those (like me) for whom the above solutions do not work: After starting the app you wish to debug, go to Debug -> Attach to Process, and attach it to the process you want to debug. Works on my machine.

jyoungdev
  • 2,674
  • 4
  • 26
  • 36
  • Though that still won't work if the process you're attaching to is being run with elevated privileges, unless you've started Visual Studio by running it as administrator (which is what OPS's solution was anyway). – the_mandrill Jun 28 '10 at 19:14
  • @the_mandrill Correct. This problem seems to have multiple possible causes, each with a different solution. – jyoungdev Jun 29 '10 at 04:33
0

Have you installed anything else on the server / workstation recently?

We have a third party app that doesn't allow us to debug, w3wp.exe crashes immediately upon an attempt to debug.

cjk
  • 45,739
  • 9
  • 81
  • 112
0

I ran into something similar when I had placed some code in a constructor that was crashing. Exact same issues where the Debug would disconnect just after the application started up.

The short if it, check that you haven't configured a class constructor to run during web startup that is crashing...

Dscoduc
  • 7,714
  • 10
  • 42
  • 48
0

In my case, I faced this issue with Visual Studio 2019 and 2022 as well. I tried upgrading/downgrading Visual Studio versions but nothing helped.

On debugging, I finally found the root cause and sharing it here to help others facing the same problem.

I was using Brave browser with Visual Studio and whenever I uploaded a file in my application, the Visual Studio debugging stopped automatically. The root cause of this issue is the feature in Visual Studio to stop debugging on closing the browser. With Brave browser Visual Studio feels like we have closed the browser on uploading the file. So to fix this issue I have turned of this setting as given here.

You can find this setting here Tools > Options > Projects and Solutions > Web Projects > Stop debugger when browser window is closed, close browser when debugging stops

Just turn it off and everything should work fine.

prem
  • 3,348
  • 1
  • 25
  • 57