views:

75

answers:

4

I'm using exceptions to validate a control's input in Silverlight 4. When I throw an invalid input exception, VS 2010 displays the popup and stops the program. I ignore this and resume the program, and everything continues fine (since the exception is used to signal a validation error.) Is there a way to mark that one exception as ignored?

I'm following this tutorial.

+4  A: 

Debug -> Exceptions -> Uncheck

Jean-Bernard Pellerin
+2  A: 

Menu, Debugger, Exceptions...

In that dialog, you can remove the checkmark in the 'thrown' column for one exception, of for a whole namespace. You can add your own. etc.etc.

jdv
+1  A: 

You can disable some throw block by surrounding in the block

#if !DEBUG
       throw new Exception();
/// this code will be excepted in the debug mode but will be run in the release 
#endif
Pomoinytskyi
Won't this stop the exception from being thrown? I want it to be thrown, I just don't want VS to stop the application and pop up that box.
Rosarch
+1  A: 

Putting this above the property that throws the exception seems like it should work but apparently doesn't: [System.Diagnostics.DebuggerHidden()]:

    private String name;

    [System.Diagnostics.DebuggerHidden()]
    public String Name
    {
        get
        {
            return name;
        }
        set
        {
            if (String.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentException("Please enter a name.");
            }
        }
    }
Rosarch