I am facing a problem in my c# webservice application. Exceptions are not handled at a certain point anymore. The application simply stops without any further messages/faults exceptions. This is what happens:
Problem:
Steps I have taken so far or other information that might be useful:
And here it comes! My original code looks like this:
try
{
//some code here throws an exception
}
catch (Exception ex)
{
throw new Exception("some message", ex); //after this line no activity anymore
}
When I change this to:
Exception myex = null;
try
{
//some code here throws an exception
}
catch (Exception ex)
{
myex = new Exception("some message", ex);
return null;
}
finally
{
if (myex!=null) throw myex;
}
my problem is solved!? Does anyone have an explanation for this behavior? I hope to rely on normal exception handling mechanisms.
Another remark: when I put a 'throw new Exception()' before the try{} section, my code runs fine as well (but of course, I do not want that).
Anyone any clue? Thanks in advance!
Are you running this from a background worker? I think you could be running into an issue with thread locking up in your first section of code, but then the return null allows the thread to finish in your second section of code.
I have seen some errors along these same lines where using a MessageBox.Show() command will allow the code to work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With