I get the following exception (in Dutch, English translation follows in the text) which breaks my debugger when I press 'OK' it stops the debug session and closes the application:
Translated in text:
---------------------------
LerTemperaturaWPF.vshost.exe - Application Error
---------------------------
INTERNAL ERROR:
Unhandled exception in Debugger::HandleIPCEvent.
Event ID=0x246.
Exception code=0xc0000005, Eip=0x68fbaeca.
Process ID=0x1094 (4244), Thread ID=0x10a4 (4260).
---------------------------
OK
---------------------------
This happens if the first time the debugger breaks are inside a certain piece of code:
private void PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// Set value of property, only when the long editor is selected (no optionlist item is selected)
if (this.Editor.SelectedItem != null)
{
if (this.Editor.SelectedItem as OptionForList == null)
{
this.Editor.SelectedValue = ((Management.Property)this.Editor.SelectedItem).Value;
this.Editor.SelectedIndex = 0;
}
}
}
It happens when I place the breakpoint inside the 2nd if statement, before the second if statement (where ever I place it). It gives me no problems.
If I make sure the first break the debugger has is before this code and afterward it hits a breakpoint in this code there are no problems either. The debugger must have broken before getting to this code. Now I do not think it has anything to do with this code (90% certain).
The property changed is a user control and somehow I think the debugger can't handle the user control properly? maybe?
Has anyone seen this behavior before and know how to fix this? do I need to turn off (or on) some of the debug settings??
Right click on the project/solution -> Properties -> Debug -> Check "Enable native code debugging".
(1) On the Debug menu->Windows->Exceptions, and enable all Thrown check boxes. Debug the application, it will show you the actual and detailed errors in a message Box.
(2) Right click on the project/solution -> Properties -> Debug -> Uncheck "Enable visual studio hosting process".
(3) Please also change the Platform target (X86/Any CPU/X64), re-compile the app, debug it again.
(4)Tools > Options > Debugging > General > "Use Managed Compatibility Mode" checkbox.
All answers described here do not guarantee 100% cure. What I am doing as a workaround is that just stepping over to the next line while debugging.After that I can see the value of that variable in the watch on mouse hover. (In my case, stepping over to next line does not change value)
Related
I'm trying to debug a variable in my code. I'm using a break point but when my mouse goes over any of the variables present in "locals" it the locals window suddenly closes down without any warning at all. Also a lot of the lines are empty. Is this a bug?
Your watch window contains an error message "Function evaluation was aborted." That probably means one of the properties displayed has an infinite recursion, like so:
readonly bool isSigned;
public bool IsSigned { get { return IsSigned; } }
Fix the infinite recursion and the problem should go away:
readonly bool isSigned;
public bool IsSigned { get { return isSigned; } }
You can catch the StackOverflowException when it is thrown using Visual Studio by selecting from the menu bar "Debug" -> "Exceptions" -> "Find..." -> type "stackoverflow" -> check "Thrown" for System.StackOverflowException -> "OK"
If "Exceptions" does not appear in the "Debug" menu of your version of Visual Studio, follow the instructions for To add the Exceptions command to the Debug menu for your VS version.
update Just checked, looks like Visual Studio won't break on the StackOverflowException if it's thrown in the watch window. If you can't find the bug by code inspection, what you have to do to find the infinite recursion is to delete everything in the watch window, then add a line or lines in your actual code to access the properties that might be causing the recursion, checkaoprimeiroradiobuttonG in your case, e.g.
var tmp1 = checkaoprimeiroradiobuttonG;
var tmp2 = desactivabetaoadicionalG;
In that case the recursion should get caught.
Normally I want the debugger to break on ArgumentOutOfRangeException.
But within my try catch(ArgumentOutOfRangeException) that exception is already handled and so I want the debugger to not break.
I tried the DebuggerStepThrough attribute, but it still breaks.
You can do this by setting the debugger to break on user unhandled exceptions.
Go to Debug -> Exceptions, Common Language Runtime Exceptions, de-tick (uncheck) the Thrown box. Of course you can get very precise with what you want to break on by drilling down into that list. Be aware that this setting takes effect across the whole solution, you can't set it per class or method. If you do want to be more selective per method, then consider using compile directives to not include that bit of code during debug time.
As for the DebuggerStepThrough attribute, that is to prevent breaking on break points, nothing to do with breaking on exceptions.
You should check your visual studio isn't set to break on all exceptions
On the Debug menu, click Exceptions.
In the Exceptions dialog box, select Thrown for an entire category of exceptions,
for example, Common Language Runtime Exceptions.
Microsoft Visual Studio Help
There is a way. First disable debugging code that is not yours. Go to Tools > Options > Debugging > General > select "Enable Just My Code (Managed only)". Now tell the debugger that this one function is not part of your code with DebuggerNonUserCodeAttribute:
[System.Diagnostics.DebuggerNonUserCode()]
private void FunctionThatCatchesThrownException()
{
try
{
throw new ArgumentOutOfRangeException();
}
catch (ArgumentOutOfRangeException ex)
{
//...
}
}
If an exception (some other than ArgumentOutOfRangeException) gets out of the function debugger will catch it as usual, but the location of interception will be where the function is called.
I'm currently learning after a book about how to convert xaml code into objects during runtime.
I have the following code:
try
{
ctrl = XamlReader.Load(xaml) as UserControl;
}
catch (Exception exc)
{
OnXamlResult(new XamlCruncherEventArgs(exc.Message)); return;
}
The code is not mine, I took it from the book.
The problem is that try-catch does not work properly, or at least as I know till now.
During debugging the program stops when it reaches the line :
ctrl = XamlReader.Load(xaml) as UserControl;
without catching the exception.
What am I doing wrong or how can I solve this problem?
"xaml" is a string. It is taken from a textbox and if the xaml is correctly typed by the user the program should convert the xaml code into object otherwise it should display the corresponding error.
About how the program reacts, i can say that debug stops(it returns me to visual studio pointing the error) and it is not behaving like going into a infinite cycle.
It's probably the debugger breaking as the exception occurs. Stick a breakpoint inside the catch and F5 to continue, it should carry on and hit your breakpoint.
And by "breaking", I don't mean it fails, I mean it pauses execution of the app on the offending line of the exception, so it's a Good Thing in this instance.
If you are using Visual Studio, you can enable/disable this "break on exception" behaviour:
Debug -> Exceptions... (Ctrl + Alt + E)
Common Language Runtime Exceptions, check the boxes to the right as needed.
As for the exception itself, unless it's there specifically to show exceptions, it is likely having trouble loading the provided XAML string.
I put a breakpoint to the last line of code. Breakpoint is disabled. Why?
It looks like the code is excluded by some condition. The constructor of TraceSource works, and I can verify the object is OK and all listeners are OK. It really looks bizarre. I stop on int a=1; and then debugger skips TraceInformation by ignoring it. The configuration is DEBUG x86.
public TraceSource _fixTraceSource;
_fixTraceSource = new TraceSource(_configSection.TraceSourceName);
int a = 1; // dummy line to set breakpoint
_fixTraceSource.TraceInformation("FIX -> toAdmin Message: {0}", message.ToString());
TraceInformation is marked:
[Conditional("TRACE")]
So you need the TRACE symbol defined at compile time for it to be included. This is usually by checking the "Define TRACE constant" box in the project properties page (it is enabled by default for both Debug and Release profiles, so somebody has unchecked it at some point).
I've been messing with VS 2010 debugging settings, trying to get stepping into the .NET Framework working. Well, I can't get it to work. I've also tried the Reflector VS plugin and that was working at one point.
Then I randomly started getting this error:
This only happens when I have a breakpoint on a line that calls IEnumerable<T>.ToList(). If I try to step-over or step-into on that line where my breakpoint is set, I get this error dialog and my debugging session ends.
If I move the breakpoint to the line below, the debugger makes it past the ToList() call!
I've tried the following to no avail:
Removing the Reflector plugin.
Undoing my changes in the Tools > Options > Debugging window (unchecked the option to step into the .NET Framework; unchecked the source server option; checked the just my code option).
Unchecked Microsoft Source Server in the Tools > Options > Debugging > Symbols window.
Cleared the symbol cache.
What is going on?
Because this was the first place I came to when I searched for an answer, I'll add what I found out.
In my case, I had the debugger set up in the solution to start multiple projects. For some reason this setting was changed by Visual Studio so that no project was starting. Correcting the setting in the solution immediately solved the problem.
The problem was not difficult to solve, but the error message was more than a bit irritating.
I've just found this answer useful. All I did was change my start-up project to another, and back to normal.
My project probably lost this setting somewhere, and resetting it made it available again.
It was a ToString() override that make the debugger crash ! (After the evaluation the debugger will show you the result with the ToString() method). And if you get an exception in the ToString(), you will never catch an exception because you cannot code them on the debugger behaviour.
I've got this answer from msdn
I suffered from same problem....
I found one solution which heard uncommon....
The debugger cannot continue running the process.Process was terminated
While debugging your code step by step , you will find the line , from where error redirecting.
If you are using " ToString() " anywhere in that file ,please remove that .
Instead of the ,you can use Value / Text .
It works fine.
............
If you were not used ToString() any where in program , then reload project copy by removing completely.
I had the same problem. I traced it down to a class(step-by-step debugging) and finally to a property(commenting all the code, then step-by-step uncommenting).
this property returned a typed dataSet from a table.Dataset
private typedDataSet myDataSet
{
return this.DataSet as typedDataSet;
}
this was in a DataTable partial class.
After I removed this property everything went OK.
I ran into this issue with a code bug from copy/paste. Instead of get/setting the private member variable, I did a get/set on itself. When I referenced the property in other code the debugger terminated (2010):
public bool ProdToDeve
{
get { return ProdToDeve; } // <= missing underbar
set { ProdToDeve = value; }
}
private bool _ProdToDeve = false;
This message will also show up when you're trying to debug a Xamarin solution but you have a class library selected as the startup project instead of your application porject.
It occurred to me when I was doing the following:
throw new Exception(timeout.TotalSeconds + " second(s)");
That's because timeout.TotalSeconds.ToString() which indeed is an override method for an object of type double, was throwing a Parameter not valid exception.
Finally, for safety I ended up doing the following:
throw new Exception(System.Convert.ToString(timeout.TotalSeconds));
Well, typically, this is also the kind of error message you can get in a multi-threads context. In brief, it involves concurrency : make sure that your resource accesses are always secured.
In my case, I got this error message when I forgot to secure resource accesses at some places within my code. To solve this issue, I just had to decorate the critical sections with a lock instruction (on the concerned resource). I hope this will help those who are in this context.