I am having a problem with a database call that throws an AccessViolationException
when I call ExecuteNonQuery()
. The call is enclosed in a try-catch
block but the exception is never caught. Instead, I get an entry about it in the Windows Event log. Is there a way of catching this exception in code?
IDbCommand cmd = ...
cmd.CommandText = "...";
try
{
var results = command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.Writeline("Caught exception: " + ex.Message);
}