Handling .NET exceptions raised during display of a .NET form
In an ABL application, .NET exceptions can occur when .NET user-interface components first display or when users interact with a .NET user interface. From the ABL viewpoint, all these exceptions occur within the context of a .NET Show( ) method, WAIT-FOR, or PROCESS EVENTS statement that is currently running in an ABL session.
.NET typically traps most such exceptions within the CLR, before they have a chance to reach the ABL context. In this case, you might see a .NET alert box displayed like the one in the following figure.
Figure 4. Alert box from the Microsoft .NET Framework
This alert box displays a message that tells you how you might fix a bug that is typically in code that initializes .NET forms, controls, or related objects.
To handle the display of a .NET alert box in the ABL context:
1. Review the message to identify the problem that caused its display.
2. Click Continue to allow your ABL application and session to continue and see what you might do to fix the problem. Also note that sometimes the .NET alert box also provides a Quit button. Do not click Quit unless you want to immediately terminate your ABL session.
However, some kinds of exceptions, such as a System.AccesssViolationException, cause System.Windows.Forms.Application:Run( ) to terminate and raise a STOP condition on the executing WAIT-FOR or PROCESS EVENTS statement. You can trap this condition using the ON STOP phrase of an enclosing block. However, because all displayed forms are closed when Application:Run( ) exits, the most that you can do is to clean-up and attempt a graceful shutdown of your application.