Reputation: 2484
I have a property bound to ComboBox
<ComboBox ItemsSource="{Binding AvailableTypes}"
SelectedValue="{Binding Kind, Mode=TwoWay}}"/>
and in the property setter I throw an exception in some business circumstances to abort setting the property.
public MyKind Kind
{
get { return kind; }
set
{
if (kind != value)
{
if (SomeRuleFailed(value))
throw new Exception("to be ate by binding code");
kind = value;
}
}
}
It works smooth except the fact that VS2010 pops up every time I raise exception. Is there any kind of exception to raise or attribute to be set so debugger left in background?
Upvotes: 3
Views: 3076
Reputation: 19175
You should not be throwing an instance of an Exception
class. You should throw an instance of a class derived from Exception
.
You can create your own exception class (and you should out of habit if you have something that's not already covered by the framework) then you can select the exceptions you want Visual Studio to break on.
Once you've created your exception class, go to Debug-->Exceptions... and then pick the exceptions you want to have the debugger break on.
Upvotes: 5
Reputation: 1368
Press Ctrl-Alt-E in Visual Studio to open the Exception configuration for the Debugger, and select or unselect what you need.
Upvotes: 3
Reputation: 21713
You can set the kinds of exceptions that cause the debugger to break by going to Debug > Exceptions. Untick the Thrown checkbox against Common Language Runtime Exceptions or pick your exception types individually.
Upvotes: 5