I have a Visual Studio App (Windows.Forms) that build a release .exe-App. If I run this exe an exception occurs, I only can see it in the windows log, nothing more happens.
But I would like to see the JIT Exception Window. Can I activate this somehow in VS?
Im asking for a general "If any exception at runtime - show the JIT Debugger"-switch. Is something like this available?
Did it now like here shown.
http://www.csharp-examples.net/catching-unhandled-exceptions/
Instead of logging made an MessageBox with the Exception Message und Application.Exit(). Works exactly as i like it to have.
Related
I'm currently using a library that throws (and handles) about 5 exceptions when a request to get something fails. Normally this isn't a problem since it's expected this might happen, but the problem is that Visual Studio will log these exceptions anyway.
Is there a way to disable Visual Studio from outputting caught exceptions to the debug console? I still want all other exceptions that would cause a break to be logged.
You can ask Visual Studio to care about the exceptions in your code only, using the Just My Code option.
Go to the "Debug" menu and click on "Options and Settings", and then Enable Just My Code:
This has been discussed on StackOverflow too.
Then, if the methods that are throwing the exception belong to a project that is... your code, you can decorate them with the DebuggerNonUserCode attribute:
which combined with the "Just My Code" option will produce the desired behaviour.
More on the topic here.
I used to be able to edit and continue when an exception occurred in my Visual Studio 2015 C# (WPF if relevant) projects. I often get simple things like null reference exceptions, and I could just quickly fix the issue and continue.
However, recently I've been constantly getting the following warning message:
"The debugger cannot unwind to this frame."
It notes that unwinding is nor possible in the following:
Debugging was started via Just-In-Time debugging. - This isn't the case, I'm debugging by running the "Start debugging" from Visual Studio.
An unwind is in progress - Not that I'm aware of, unless for some reason it's always in progress!
A System.StackOverflowException or System.Threading.TreadAbortException - This happens on all exceptions, including simple ones like Null Reference
My googling comes up with a few articles saying they've implemented this feature in 2006, other than that, only about 3 results come back!
It seems to be project specific. In a clean new project:
Object o = null;
String s = o.ToString();
Throws an exception, and lets me edit and continue the line before. In my existing project I cannot unwind and it throws up the dialog.
Edit: Tried it with a different computer and Visual Studio install and still have the issue.
It seems to be an issue with Caliburn Micro.
If I have a button on my user interface linked to an event in the code behind with the above code, I can rewind and debug. However, If I use cal.message.attach and put the code in the referenced ViewModel's method, then I cannot unwind. But I'm not sure.
You can try and test these solutions one by one.
Unwinding exceptions is unreliable in optimized code. Debug | Options - Check 'Enable Just My Code'
Debug | Options - Check 'Use Managed Compatibility Mode'
Debug | Options - Uncheck 'Enable property evaluation and other implicit function calls'. If that doesn't work, also:
Debug | Options - Check 'Use the legacy C# and VB expression evaluators'
Debug | Windows | Exception Settings - Expand the 'Common Language Runtime Exceptions' dropdown. Make sure your exception is checked.
I am trying to debug Windows 8 C# Store application with Local Machine debugger. So, I added some incorrect line to MainPage constructor, after InitializeComponent call. I tried the code that causes DivideByZero or NullReferenceException - with the same results.
So, I execute "Start Debugging", and debugger breaks here:
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
Stack information is not available, it is impossible to detect where is an error (only first-chance exception message in the Output window gives a hint).
I tried to define DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION in the project preprocessor symbols. This time I got the following strange message: "A debugger is attached to YourProgram.exe but not configured to debug this unhandled exception".
Only when specific exception type is checked in the "Exceptions" dialog, and DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION is defined, I managed to break on the line which caused the error.
So, what is the right way to break on the offending line, like is was in traditional desktop applications debugging? If possible, without modifying Exceptions list. And what is exactly the purpose of DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION constant?
It looks like a xaml parsing exception. Have you be able to look at the exception message and see where the error is?
Here is some sample screenshot:
Well when you start Visual Studio you must click on debug and then Options and Settings and then General in Debugging and click on Enable Just My Code.
It can be helpful to enable "Common Language Runtime Exceptions" in "Debug/Windows/Exception Settings" before debugging.
Visual studio will now break on the actual error.
while i am calling a method which is declared in another project. calling project and called project are presented in same solution.
I am getting a error window that says:
Window Tile : Test.vshost.exe
Test.vshost.exe has encountered a problem and needs to close. we are sorry for the inconvenience.
(I will make disappear the error window by clicking "Dont Send" button)
what is the reason for such this error.
Note: I have included the refereed project in reference.
I used call a methode as follows
ReconcileDBService.InsertRecordInT_AUDIT_Incident(keyCase);
Above methode declared as follows
public static void InsertRecordInT_AUDIT_Incident(string keyCase)
We can't really help you based on the data you provide...
Is your program using Win32 or COM interop ?
Try to add breakpoints and debug messages to pinpoint the problem. Once you know the exact location where the problem occurs, it will be easier to understand it.
Turn off the "Visual Studio hosting process" and start your session again. Maybe you get some better or more information about an exception that is raised by your programm.
You can do this under the Project-Properties-->Debug-->Enable the Visual Studio hosting process (uncheck)
Also you could check the build order of your projects. It may be that the "Visual Studio hosting process" uses a diffrent assembly version than your programm expects.
Press Ctrl-Alt-E (Debug->Exceptions) and in the 'Break when an exception is:' selection, select everything.
Start a debug session with the application.
The debugger should now stop at the crash and you should be able to look what you are sending to the other project, and maybe solve your problem.
This is nearly my first experience with unit testing.
I added a unittest to my solution, and selected Test->Run->All Tests in Solution. My test failed due to an exception which got thrown in the tested code.
Normally, I would then go to the stacktrace toolwindow, click my way through it, looking at the values of locals in every stackframe, and figure out what went wrong. But when code fails within an unittest, I don't get the normal "yellow balloon" exception notification, and I'm not able to explore the stacktrace in detail. All I get is a "TestMethod1 [Results]" tab, which displays only the exception message and a plaintext stacktrace. So, no access to the values of locals, no access to any debug-output I may have printed to the console...
How am I supposed to debug it then?
You need to select "Test->Debug->All tests in solution" then the debugger works as normal.
All the normal debug windows are available by going to "Debug->Windows".
You can install TestDriven.NET, which is a Visual Studio add-in that allows you to do just that - debug your tests. There is a free community version.
You can put a breakpoint in your code, like this:
<TestMethod> _
Public Sub Test() <--- Put breakpoint here.
and then choose to debug the unit test, you can then step through the code.