CodeBlock from C#
Posted: Thu Oct 30, 2025 5:47 am
Hi everyone,
I'm working on a C# unit test where I use a dbSysDat instance derived from dbShellServer. When the underlying DBF file is missing, the VO.dbServer throws an error and displays a modal dialog.
From what I understand, this modal dialog is the default behavior and can be overridden by assigning a custom ErrorBlock. This seems to be straightforward in X#, but I'm unsure how to create and pass a CodeBlock from C# to the ErrorBlock function.
My goal is to handle the error in one of the following ways:
Log the error message to the test output
Throw it as a regular exception
Or suppress it entirely
Is it possible to achieve this from C#? If so, how would I go about creating a compatible CodeBlock or delegate?
Thanks in advance for your help!
Best regards,
JoeD
I'm working on a C# unit test where I use a dbSysDat instance derived from dbShellServer. When the underlying DBF file is missing, the VO.dbServer throws an error and displays a modal dialog.
From what I understand, this modal dialog is the default behavior and can be overridden by assigning a custom ErrorBlock. This seems to be straightforward in X#, but I'm unsure how to create and pass a CodeBlock from C# to the ErrorBlock function.
My goal is to handle the error in one of the following ways:
Log the error message to the test output
Throw it as a regular exception
Or suppress it entirely
Is it possible to achieve this from C#? If so, how would I go about creating a compatible CodeBlock or delegate?
Thanks in advance for your help!
Best regards,
JoeD