Do not interrupt while debugging

This question seems very similar to the previous one , but the case is a little different (perhaps it better demonstrates the problem), although the goal is the same.

XAML:

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

CS:

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

ut:

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

When this code works offline, for input 123 a red frame is displayed around the TextBox (the value of the field does not change). Entering red or #FF0000 will remove the boundary and update field value.

Problem: when starting the program in Visual Studio, 123 input will be issued when ConvertFromString ( undocumented btw):

An exception of type "System.FormatException" occurred in PresentationCore.dll, but was not processed in user code

Additional information: the token is invalid.

How to prevent Visual Studio from interrupting program execution?

+5
source share
1 answer

You can choose which Visual Studio exception to break by clicking on ' CTRL + D + E ' or click on Debug, Settings and Exceptions (see MSDN for more information: https://msdn.microsoft.com/ en-us / library / x85tt0dd.aspx )

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

After that, just pay attention to the output window for such exceptions ...

+3
source

Source: https://habr.com/ru/post/1243673/


All Articles