Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 307
Sinatr Avatar asked Oct 19 '22 14:10

Sinatr


1 Answers

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...

like image 51
cdie Avatar answered Oct 21 '22 04:10

cdie