I'm trying to write a unit test which has to throw a specific SqlException with Number 1205 or 1222. After fallowing this (because SqlException is sealed) now I have to use reflection to set the Number property which is read only. I've tried using Mono.reflection but using the fallowing code I get an exception:
typeof(SqlException).GetProperty("Number").GetBackingField()
.SetValue(exception, SqlDeadlockViolation);
Exception: "Value does not fall within the expected range."
Any idea on how I can set the Numer property?