Visual Studio Just-In-Time Debugging Annoyances - debugging

I have a solution comprising of about 6 projects, and when I debug on one machine, any un-handled exceptions that occur cause the environment to break at the point that exception is thrown, allowing me to debug it.
However, on a different machine with the same solution (in the same version of VS), all I get when an exception is thrown is the "Visual Studio Just-In-Time debugging" window popping up, which tells me the name of the exception, and little else - it offers to open a new visual studio instance in order to debug it, but that doesn't work, because it is already being debugged by the IDE!
What is going on, and how can I get back to visual studio telling me where the exception happened?
Cheers

You might want to check Exceptions in the Debug menu (mapped by default to Ctrl+Alt+E) and verify that both machines have the same exceptions selected.
Probably on the second machine you have less exception types selected in that window. When one of the exceptions that are not selected is thrown:
the debugger does not handle it because it has been instructed not to
the exception gets passes to the OS
the OS launches the default system-wide debugger which is the "Visual Studio Just-In-Time debugging" launcher if you installed VS2005 on that machine.

Sounds like it can't find the debug info.
Try copying the PDB files to your output directory.

I've had this problem as well - two machines, identical exception settings, different behaviours. The solution for me was to set the Debugger Type in the project properties on the "bad" machine to Mixed, even though the application only contains managed code. On the "good" machine exceptions are caught in Visual Studio using the Managed Only setting.

Related

Visual Studio 2013 breakpoints aren't hit

I recently installed visual studio 2013. In VS2013 i've opened a VS2010 solution.
As i wished to debug the application, i've set some breakpoints on code that are always hit. secondly i've included the option to break on exception (so i know exactly where it went wrong).
yet when i run the application (in Debug)
The exception isn't caught. The exception goes through the normal channels of handling without popping up to me.
None of the breakpoints are hit.
The solution had never such problems in VS2010. Another solution (built & created under VS 2013) doesn't give any problems during debugging. With all the exceptions being thrown and all the breakpoints being hit.
What have i done wrong?
What i've tried sofar:
reinstall VS2013
Changed targeted framework
Clean & rebuild
Attached to process
....
Thank you for your time
I noticed that you attached the process, have you manually detemine the type of code to debug ?

A first chance exception of type 'StructureMap.StructureMapException' occurred in StructureMap.DLL

Hello I'm getting this exception thrown at me whenever I try to test a web application via visual studio, any ideas why? I'm building a project using MVC3 model and visual studio 2010
Exception: A first chance exception of type 'StructureMap.StructureMapException' occurred in StructureMap.DLL
First chance exceptions might occur while debugging. They might be handled properly by your code and never propagate when running the application normally but nevertheless Visual Studio shows them in Debug mode. If you don't want to be bothered you could disable them in Visual Studio and they will no longer appear.

Program won't start unless debugging

I have a program I made using Visual Studio that won't start unless VS is debugging. Where should I look for problems?
The program works when debugging through VS but won't start from the debug folder. The program works fine when debugging. No output is given.
For this sort of startup problem I'd suggest running your app in Windbg (part of the Debugging Tools for Windows). Do File -> Attach to executable and then hit F5. You should get more informative output there. I suspect it's a dll dependency or manifest problem. Another useful tool is the Dependency Walker which may highlight some dlls that are on Visual Studio's path but not your default path, which may also explain the error. Another thing to try is check that all types of debug output are being shown in Visual Studio: right-click to get the context menu in the debug output window and ensure it's showing exception messages and module load messages.
Try turning on Stop on Exceptions
Debug - Exceptions - Common Language Runtime Exceptions (thrown and user unhandled)

How to stop "Just In Time Debugging" messages blocking a buildserver

Our buildserver (TeamCity, much recommended), runs our a whole bunch of testsuites on our finished c++ program.
Once in a whole, a test causes our program to crash, often bringing up a VisualStudio dialog offering me to JustInTime debug the crash. The dialog stops the buildserver from progressing. Instead of the build marked as failed, it just hangs. I've turned off the Just In Time debugging feature in VisualStudio, but when it's turned off, you still get a message "Couldn't JustinTime Debug this, you can turn it on in the options".
Does anybody know of a way to ensure that any unhandled exception in a program does not result in any modal dialog?
This MSDN article explains how to disable Just-In-Time debugging on a Windows server. I've included the relevant portion of the article below:
After Visual Studio is installed on a server, the default behavior when an unhandled
exception occurs is to show an Exception dialog that requires user intervention to
either start Just-In-Time debugging or ignore the exception. This may be undesirable for
unattended operation. To configure the server to no longer show a dialog when an
unhandled exception occurs (the default behavior prior to installing Visual Studio), use
the registry editor to delete the following registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
On a 64-bit operating system also delete the following registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
Delete (or rename) c:\windows\system32\vsjitdebugger.exe.
I tried deleting the registry keys, and I tried unchecking all the boxes in the Visual Studio options, but neither worked.
To be clear, my situation wasn't a C++ one. I was using Micro Focus COBOL for Visual Studio 2010, and by using the registry and VS options suggestions I managed to get rid of the "Want to debug?" dialog, but that resulted in a different dialog to hold up my automated process:
Visual Studio Just-In-Time Debugger
An unhandled exception ('COBOL runtime: Fault detected') occurred in CASDBC.exe [3564]. Just-In-Time debugging
this exception failed with the following error: No installed debugger
has Just-In-Time debugging enabled. In Visual Studio, Just-In-Time
debugging can be enabled from Tools/Options/Debugging/Just-In-Time.
Check the documentation index for 'Just-in-time debugging, errors' for
more information.
OK
I would not recommend to edit/remove regs. Usually the registry is a mess to play with.
The solution that helps me is a quite simple. I`ve just added JIT debugger to my Visual Studio. Steps are:
Open Windows Control panel
Programs
Programs and Features
Find Visual Studio 2017
Click Change. On a new opened window navigate to the Individual Components tab
Check Just-In-Time debugger checkbox
Click modify
After VS reload the error should be fixed.
In my case , on win2012 server, I tried:
removing registry keys
deleting the exe for the jit debugger from c:\windows\system32
and it still came up!
I rebooted, etc.
Was making my web site in IIS stall until dialog was acknowledged!
Final solution, which did work: In control panel, in Programs: Uninstalled "Microsoft Visual Studion 2010 Shell (Isolated)" Uninstalled that, and problem solved.
(Whether SQL Management Studio still works.... I do not know!)
In the Window for the question
Do you want to Debug using the selected debugger?
Click YES (new window opens) > OPTIONS (top row menu) > DEBUG
Then in the New window remove the TICK which shows ENABLE JUST IN TIME DEBUGGER.
After disabling the JUST IN TIME debugger close the window or click OK
Your problem will be solved. I've tried this and got rid of the JUST IN TIME POP UP messages.
Best Solution for this problem is so simple
2 steps to make it done
open cmd prompt
type : regedit
go to path-->HKEY_LOCAL_MACHINE-->SOFTWARE-->Microsoft-->Windows NT-->CurrentVersion-->AeDebug
You can find now the file : Debugger
right click , Modify
copy and paste this text inside it:
drwtsn32 -p %ld -e %ld -g
click ok and voila :)

Visual Studio 2005 - can not open form on designer

My team developed a GUI application on Visual Studio 2005, managed C++. Since some deliveries it is not possible to open the form in the designer, even if the source code and the project settings have not been changed. The designer reports this error:
Exception of type 'System.OutOfMemoryException' was thrown.
at Microsoft.VisualStudio.Design.VSDynamicTypeService.ShadowCopyAssembly(String fileName)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String codeBase)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
...
We successfully recompiled the project but we still encounter this problem.
Any idea?
This is how I used to debug these issues, Start a second instance of visual studio, load your project and attach to the first instance which also has the project loaded. Now set a breakpoint in the constructor and Page Load events and also any custom paint events that you may have in the form in the second instance and try to open the designer in the first instance, the breakpoints should get hit and you should be able to see what's going on.
I suspect that you have a Design Mode error where an infinite loop (or recursive control creation) occurs on the concerned Form.
One thing that helped me in these kinds of error on Windows Forms would be the following:
Open your Visual Studio 2005 solution for your GUI application. Don't open your form yet
Open another instance of Visual Studio 2005
In the second instance, Attach (Debug -> Attach to Process) the first instance of devenv.exe to the debugger. Make sure exceptions (Debug -> Exceptions) have all exceptions checkboxes under "Thrown" checked.
Now go to your first VS2005 instance and open the form. The second VS2005 instance will stop at the line where the error occurs.
This is a long shot, but try closing and opening the designer several times in a row. I have had the same kinds of problems with the C# Windows Forms designer (VS2005) : the form usually ended up opening correctly (after 5 tries, quite consistently).
I've run into the same issue intermittently when working with a large multi-project solution, or a project with an exceedingly large and complicated windows form.
I was able to solve the problem by enabling Visual Studio to use more than 2GB of memory. Here's the process...
(note: this assumes XP and Visual Studio 2005 - Vista and/or VS2008 will require slight changes)
Edit Boot.ini
Right-click My Computer, properties, Advanced tab. Under Startup and Recovery click Settings. Click the Edit button, and add the /3GB switch to the end of the [operating systems] line:
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /3GB
Make Visual Studio "Large Address Aware"
Run a Visual Studio Command Prompt, and change to the IDE directory:
cd %ProgramFiles%\Microsoft Visual Studio 8\Common7\IDE
Use the microsoft tool editbin to modify devenv.exe:
editbin /LARGEADDRESSAWARE devenv.exe
Now reboot, and you're done!

Resources