Visual Studio 2008 Debugger randomly dying - c#

I am having a rather bizarre error when trying to debug a .NET web application.
My system: Windows 7 Ultimate (IIS7), Visual Studio 2008, DotNetNuke 4.8.2.
I have a Web Application which I am trying to attach the debugger to w3wp.exe. I set a breakpoint in my code: could be an ascx.cs page or a library I am referencing.
Here's the weird part. Once I run through that part of the website, the code breaks, and I am able to debug, step through between 1-20 lines of code, and all of a sudden it's as if I pressed Continue. The timing doesn't seem significant (sometimes it happens after 2 minutes, sometimes after 2 seconds) and there are no error messages in the output or Event Viewer.
If I try to attach the debugger with managed and native, it goes to disassembly mode for w3wp. Again, no real obvious error.
Anyone can at least point me in the right direction as to what could be interrupting the debugger? Without any error messages, I cannot even begin to figure out where to go next.
I've tried:
Rebuilding the website configuration in IIS
Check the app pool settings to make sure it's not timing out
disabled every conceivable service on my computer
Resetting my Visual Studio settings
Rebuilding the project

This is a bug in the VS2008 SP1 debugger. MS released a hotfix some time ago:
http://support.microsoft.com/kb/957912
The bug is described on that page as:
Stepping when you debug a managed
multithreaded application can randomly
turn into a "go"

Related

Code runs, but reports that I am debugging in release build

I have an application where I can start it out in debug mode, and everything will run fine for several minutes until it will randomly pop up a box saying "You are debugg in a Release build of ***. Using Just My Code with Release builds using compiler optimizations results in a degraded debugging experiance...
I am running multiple projects at a time (they all depend on each other)
The project that it is erroring on is a class library that is referenced by both console applications and Web Api applications and is housing my data layer.
I have checked in the configuration manager and everything under debug is set to debug.
When I mention random above, at times it will error when I am trying to use the application, while other times it will error when sitting idle.
I have attempted to do a repair on Visual Studio and am using Visual Studio 2015.
I have also had other errors such as IIS Express just quit working out of nowhere, and I am using a machine with very good performance.
Does anyone have a suggestion on what I can troubleshoot next? I just wouldn't think that it would be the code if the code is being executed before the error just fine.
I finally figured out the "fix", which is very strange. I went in and enabled Suppress JIT optimization and everything went to working. I then disabled it to ensure that was the issue, but it has continued to work. I am not sure how this fixed this issue, but all appears to be working now.
Also, I am running Update 3 as asked above.

visual studio exits debugging without any exception or error

I have a TCP/CLIENT game server project in Visual Studio 2010. When I start the project in debug mode, some time later (sometimes 1 day, sometimes 1 week) Visual Studio quits debugging without any exceptions or errors. I checked the windows and application log and there is nothing unexpected there.
How can I find out what the real problem is or what (e.g. some exceptions like stackoverflow) can cause the Visual Studio exit debugging?
I assume that your application is multithreaded. In that case uncaught exception in a background thread will crash your application. It will stop your debugger as well since it can't debug all threads at a time and should be manually swiched to a specific thread using Threads window. So the solution is to catch the exceptions in async handlers and at least log them.
This worked for me (for a similar problem - not exactly this); try to reset Visual Studio environment:
devenv.exe /ResetSettings
If you are running something as server in IIS, you can try to disable health monitoring for your server project. So open IIS and right click the application pool. Find the Ping enabled setting, it's under advanced settings and set it to False. An other option is to increase the maximum response time. This is a better solution I think. Set it to about 600 seconds.
If you are debugging for a week, use intellitrace.
You can use this youtube video about intellitrace in Visual Studio 2010 as reference.

Visual Studio 2010/2012: when Stop Debugging on breakpoint hit debugged process hangs and is unkillable

Happens with some occasion.
Running Windows 8 x64, with Visual Studio 2012 Professional (also happened before in VS 2010).
C# console project being debugged with "Enable native code debugging".
Pressing F5, debugging some code, reaching breakpoints, etc. then pressing Shift+F5 (Stop Debugging) and the Visual Studio does not return to editing mode as normally, it just hangs for a while and then gives an option to terminate the hanging operation (dialog window "A remote operation is taking longer than expected" with progress bar and Terminate button). If I don't click to terminate, it stays there just updating the progress bar.
If I click to terminate the operation, VS returns back to editable mode but the debugged process is still visible in Task Manager and its not killable. This pending debug process locks certain files it uses (e.g. DLLs) so further rebuild is not possible. The only way to kill this process is to restart the machine.
Interestingly it happens when the breakpoints are reached in debugged code and debugging is performed step by step. If I just run the debugging process without breakpoints then the hang does not occur.
Solutions in the following thread didn't help: https://connect.microsoft.com/VisualStudio/feedback/details/504538/
We have faced similar issues before using 2010, but couldn't figure out the root cause yet.
The workaround was to run the process separately (console, double click the .exe) and do Debug->Attach To Process.
Note: If you wanna debug start up code then this might not be a good idea.
I was experiencing some serious unaccountable issues regarding file locks and weird behaviour of the debugger a while ago. I solved them by activating application experience service. I don't know why but after activating it all my problems regarding debugging silently vanished...
I came across a similar hanging problem and solved it. Trying it may heal your wound (it is for windows forms, but since you're on console, it is worth giving a try):
Windows Form Won't Display in Debug Mode
Please let me know if it works or not.

Visual Studio 2012 Express debugging explorer.exe - no breakpoint hit

I have problem with debugging SolidWorks Enterprise PDM addin. I don't know how the addins are handled within EPDM, but the problem seems to be related with Visual Studio - maybe someone else has similar problem with other platform's addins.
Adding a debug addin (so that latest source is used):
In Visual Studio 2010 Express there's no problem - kill explorer, start it, attach to it and:
I couldn't achieve the same with Visual Studio 2012 Express. Although it seems that it is debugging explorer (files are read-only, stop debug button is shown), it doesn't hit breakpoints:
I work on Windows 7 Professional x64. Addins are built with .NET 3.5. I've used both VS2010 and VS2012 solutions with the same problem.
I do restart explorer.exe, so the latest version of addin is loaded. Project uses start action "explorer.exe":
<StartAction>Program</StartAction>
<StartProgram>$(windir)\explorer.exe</StartProgram>
<StartArguments></StartArguments>
I don't know why the breakpoints are not hit, any help much appreciated.
Thanks!
UPDATE 1
I've checked what Hans suggested - there are two other processes starting, but attaching to them didn't result in anything.
That pointed out one more thing - when I was attaching to those processes there was an information within VisualStudio, that the breakpoints will not be hit, because no debug symbols were loaded - notice that in the third image attached the debug symbols are loaded (the red circle is filled and without the exclamation mark).
UPDATE 2
When I attached VisualStudio to the managed explorer.exe - the breakpoints were hit!
It seems that explorer.exe is running in Managed mode only sometimes:
It can even be running in both modes side by side:
So the question is how to force VisualStudio starting explorer.exe in managed mode?
UPDATE 3
Is it possibly a VisualStudio 2012 bug?
When debugging with VS2010 the explorer is started in normal mode, but as soon as the addin is loaded, it is switched to managed mode and VS2010 stops at the breakpoints.
With VS2012 it is different - when the addin is loaded, explorer.exe is not switched to managed mode and (therefore? is it connected?) breakpoints are not hit.
But when VS2012 is attached to the explorer.exe that already is in managed mode, it stops at breakpoints.
UPDATE 4
I've managed to reach the essence of the problem - when attaching VS2012 to another process (e.g. explorer.exe) with "Automatically determine the type of code to debug" selected" and the process is started in native mode and some time later loads managed code - the debugger doesn't stop at the breakpoints. When the process is already in managed mode when attaching to or when attaching to with code type(s) explicitly selected ("Managed (v3.5, v3.0, v2.0)") - the debugger stops at the breakpoints.
Already posted on connect - awaiting solution. Please vote if you experience the same problem as described in this update.
UPDATE 5
I've just tested it on a simple managed shell extension so it is not SolidWorks Enterprise PDM - related.
I've also posted a more precise bug on connect.
UPDATE 6
As of the beginning of 2013 Microsoft claims that it is a design decision that the debugger is not behaving as expected. More details in the first connect bug report.
When you're building a .dll (I assume this way it's loaded into explorer) breakpoints had always problems (at least in my experience), because you have no way of knowing in advance where file will be loaded in memory, therefore it's hard to add a breakpoint.
You may try to add manual breakpoint invocation inside your code (which is int3). In C++ this would be:
asm {
int 3;
}
In C# there's a method for that:
System.Diagnostics.Debugger.Break()
Try to adding to the beginning of your function/code part (don't forget co compile in debug mode).
Then you'll just start debugging application (.exe) which loads .dll file and loaded library should trigger a break point.

How to correctly debug web applications on local IIS 7.5 with VS 2010 Beta2?

I'm sort of new to developing Asp.net webapplication projects while running them on a local IIS. Till now I used the 'Use Visual Studio Development Server' option.
I'm using Visual Studio 2010 Beta 2.
Edit: less complex sample code
Following code sample:
List<string> _list = new List<string>();
_list.Add("asd");
_list.Add("asd2");
_list.Add("asd3");
Now I want to debug / step through some line of codes with _list.
While using 'Use Visual Studio Development Server' I can see the contents of _list in the quick watch.
If I select 'Use Local IIS Web server' and debug through the same piece of code, the quickwatch tries to display me the same values by showing me a spinning wheel for about 10 seconds with a resulting 'Function evalutation disabeld because a previous function evalution timed out. You must continue execution to reenable function evalution' message.
Afterwards I get a windows error dialog with 'Unhandeld win32 exception occured in w3wp.exe [844] The Just-In Time debugger was launched without necessary security permission..'
I do run Visual Studio 2010 Beta 2 as Administrator. I start debugging by pressing F5. It seems that I can't really debug this way. Do I somehow have to attach the VS debuggerto the IIS process? If yes, how to do so?
What am I doing wrong, and how to solve it?
And by the way, is that erroneous behaviour new in VS 2010? I've never expierencied that in VS 2008.
Just-In-Time debugging is a
feature that launches the Visual
Studio debugger automatically when a
program, running outside Visual
Studio, encounters a fatal error.
One one hand it is an indication that
your process is crashing due to some
error.
Try disabling JIT Debugger. I have not used VS 2010 RC but process in VS2008 are as follows.
Tools -> Options -> Debugging -> Just-In-time and then uncheck the all just in time checks. Click okay.
Hope this helps
I found the solution. After enabling Windows Authentification for my Website in the IIS it worked. Hope this helps anybody in the future.

Categories

Resources