Sinatr
Sinatr

Reputation: 21999

Do not break during debugging

This question seems very similar to previous, but the case is a bit different (perhaps better demonstrating the problem), though goal is the same.

xaml:

<TextBox Text="{local:ExceptionBinding Path=Color1}" />

cs:

public class ExceptionBinding : Binding
{
    public ExceptionBinding()
    {
        ValidationRules.Add(new ExceptionValidationRule());
    }
}

vm:

    Color _color1;
    public string Color1
    {
        get { return (new ColorConverter()).ConvertToString(_color1); }
        set { _color1 = (Color)ColorConverter.ConvertFromString(value); }
    }

When this code runs standalone, for input 123 red border is shown around TextBox (field value is not changing). Entering red or #FF0000 will remove border and update field value.

Problem: when running program under Visual Studio, entering 123 will throw at ConvertFromString (undocumented btw):

An exception of type 'System.FormatException' occurred in PresentationCore.dll but was not handled in user code

Additional information: Token is not valid.

How to prevent Visual Studio from interrupting program execution?

Upvotes: 5

Views: 395

Answers (1)

cdie
cdie

Reputation: 4544

You can choose on what exception Visual Studio break by pressing 'CTRL + D + E' or hit "Debug" Menu, Windows and Exception Settings (see MSDN for more infos : https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx)

Thent uncheck the exceptions you don't want to see (for converters, just uncheck CLR exceptions)

After that, just pay attention to the Output Window for that kind of exceptions...

Upvotes: 3

Related Questions