Always continue after an exception
Marco
Posts: 19
Hi
I have a trial version of SmartAssembly 5.1. I'm testing the "Automated Error Reporting". The problem is the setting "Always continue after an exception", because it doesn't work. After sending the error report, my program will close. I use the standard template.
Thanks
Marco
I have a trial version of SmartAssembly 5.1. I'm testing the "Automated Error Reporting". The problem is the setting "Always continue after an exception", because it doesn't work. After sending the error report, my program will close. I use the standard template.
Thanks
Marco
Comments
Am I right in assuming that certain types of .NET Runtime exceptions will not let a program continue, no matter what?
SmartAssembly's description of this feature is carefully-worded (it will attempt to continue).
Do you have a list of exceptions that my program will close and which not?
Can I control, which exceptions will close my program?
You attach to each method and property following code:
try
{
//MyCode
}
catch (Exception exception1)
{
UnhandledException.CreateExceptionX();
throw;
}
Is there a way to omit the "throw;"?
Thanks
Marco
Also if the exception occurs within the assembly's entry point then you wont be able to continue.
Unfortunately it is not possible to specify in the UI which exceptions to continue from. However, if you have the Pro version of SmartAssembly it is very easy to customise the error reporting template and add a little bit of logic which changes the value of ReportExceptionEventArgs.tryToContinue (as passed to OnReportException) depending on the exception type.
The throw is required unless you apply the ReportExceptionAttribute to the methods (which mean the exception is caught, reported but not propagated). SmartAssembly is designed to preserve the exception handling semantics of your code so that if you have your own try/catch block for a particular exception SmartAssembly will not interfere with it, for this reason the exception is left to propagate until nothing else handles it.
I have tested OverflowException, ArgumentNullException and DivideByZeroException. Unfortunately my program is always closed. If I use the ReportExceptionAttribute, then my program is not closed.
What is the problem?
Thanks
Marco
Are you doing any global error handling yourself?
I have changed my test project to a Windows Forms Application and now everything works. However, this is not the solution, as we work with WPF.
Thanks
Marco
WPF has an extra unhandled exception event in the framework to WinForms. The events common between WPF and WinForms will work on WPF, however, in WPF they are both raised at a point where the application can't continue (it is possible to continue when the extra event in WPF is raised).
I've logged a bug in our tracking system (SA-376) for our developers to fix.
The only workarounds I can suggest in the meantime is either use the "ReportExceptionAttribute" on every method (which I know would be a real pain), or if you buy the Pro version you just need to add a handler for the missing event:
Somewhere near the start of your application add a line:
and then add the method to handle the event
(note you do need the Pro edition as the SDK, which ReportException.ExceptionReporting is part of, requires the Pro edition or Team package)