I have the following:
private int order;
public int Order {
get { return order; }
set {
if ((value < 0) || (value > 99)) {
throw new Exception(string.Format("{0} must be between 0 and 99", value.ToString()));
} else {
order = value;
}
}
}
This is called here:
try {
property.SetValue(reference, convertedValue, null);
} catch (Exception e) {
var a = e;
}
When I set a value of 50 everything works okay. When I set the value to 123 and step through with the debug it goes to the property.SetValue line and then next thing is it gives me this and points to the end of the "} else {" code block in the first code snippet.
System.Exception was unhandled by user code
HResult=-2146233088
Message=123 must be between 0 and 99
Source=Test.Storage
StackTrace:
at Storage.Models.Reference.set_Order(Int32 value) in C:\Code K\139- Aug 23\Common\Storage\Models\Reference.cs:line 22
InnerException:
Can someone explain why the exception is not handled? I can't understand why it would not be caught with the try loop that surrounds property.SetValue. I have a debug point on var a = e; but it doesn't go there.