-
Amrutha P
- PowerBuilder
- Wednesday, 4 February 2026 04:26 AM UTC
We’re migrating an application from a PowerBuilder WinForm target (sybase - 12.5.2) to a Classic PowerBuilder target (Appeon - 2022 R3) and are running into an issue with exception handling when calling a .NET DLL.
In the WinForm target, we were calling a .NET DLL inside:
#IF PBDOTNET THEN
with proper TRY / CATCH handling.
When the DLL throws a business validation error, it is caught as a System.Exception, and we could read and handle the actual business validation message correctly.
After moving to Classic PowerBuilder, we’re using the .NET DLL Importer. We wrap the imported .NET class calls in TRY / CATCH, (option to automatically wrap method calls in TRY / CATCH provided by .Net dll importer) but now:
- The CATCH only receives a runtime exception.
- The original business validation error from the DLL is lost.
- PowerBuilder throws “Error calling external function (runtime error)” instead of the real business error.
One more observation:
- If we do not wrap the DLL call in TRY / CATCH, the application crashes when the DLL throws an exception.
So, we have two problems:
- With TRY / CATCH: no access to the actual business validation error
- Without TRY / CATCH: application crash
Has anyone faced this in Classic PB?
Is there a workaround to:
- Capture the original .NET business exception message, or
- Handle .NET exceptions more gracefully in Classic PowerBuilder?
Any guidance or patterns that work in Classic PB would really help.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.