[BUG in cf] SqlException

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

SqlExeption.Message is not override in CF.

I have a SqlException happening in my code

I treat it in a Global method:
OnException(Exception e)
{
string s = e.Message;
}
the message is "SqlException"
however if I cast my exception to SqlException

I have
OnException(Exeption e)
{
string s = e.Message;
if(e is SqlException)
s = ((SqlException) e).Message;
}
in this case I have a different message like "INSERT statement conflict
....."

so it seems that the Message method has not been correctly been overwrite
(with the overwrite keyword)
 
Well I discover that with the debugger.
when I try to cast to SqlException I didn't find the assembly containing the
type (??!!! not in System.Data.SqlClient ???!!!)

anyway using a bit of reflection:
PropertyInfo pi = e.GetType().GetProperty("Message", typeof(string));
return (string) pi.GetValue(e, null);

I confirm the problem
 
Lloyd Dupont said:
SqlExeption.Message is not override in CF.

Indeed. That's a bug which I've brought up in the past too. Apparently
it'll be fixed in the next version...
 
Back
Top