Debugging .NET CLR routines

Debugging .NET CLR routines might be required if you fail to be able to create a routine, invoke a routine, or if upon invocation a routine does not behave or perform as expected.

Before you begin

Attention: With the release of Db2® 11.5.9, support for Microsoft .Net common language runtime (CLR) routines is deprecated and might be removed in the future. If you are currently running routines that have a dependency on .NET CLR, rewrite the routine logic in a supported language and then recreate the routines.

About this task

Consider the following when debugging .NET CLR routines:

Procedure

  • Verify that a supported operating system for .NET CLR routine development is being used.
  • Verify that both database server and database client are supported for the .NET CLR routine development.
  • Verify that supported Microsoft .NET Framework development software is being used.
  • If routine creation failed:
    • Verify that the user has the required authority and privileges to execute the CREATE PROCEDURE or CREATE FUNCTION statement.
  • If routine invocation failed:
    • Verify that the user has authority to execute the routine. If an error (SQLCODE -551, SQLSTATE 42501), this is likely because the invoker does not have the EXECUTE privilege on the routine. This privilege can be granted by any user with SECADM authority, ACCESSCTRL authority, or by any user with EXECUTE WITH GRANT OPTION privilege on the routine.
    • Verify that the routine parameter signature used in the CREATE statement for the routine matches the routine parameter signature in the routine implementation.
    • Verify that the data types used in the routine implementation are compatible with the data types specified in the routine parameter signature in the CREATE statement.
    • Verify that in the routine implementation that the .NET CLR language specific keywords used to indicate the method by which the parameter must be passed (by value or by reference) are valid.
    • Verify that the value specified in the EXTERNAL clause in the CREATE PROCEDURE or CREATE FUNCTION statement matches the location where the .NET CLR assembly that contains the routine implementation is located on the file system of the computer where the database server is installed.
    • If the routine is a function, verify that all of the applicable call types have been programmed correctly in the routine implementation. This is particularly important if the routine was defined with the FINAL CALL clause.
  • If the routine is not behaving as expected:
    • Modify your routine such that it outputs diagnostic information to a file located in a globally accessible directory. Output of diagnostic information to the screen is not possible from .NET CLR routines. Do not direct output to files in directories used by the database.
    • Debug your routine locally by writing a simple .NET application that invokes the routine entry point directly. For information on how to use debugging features in Microsoft Visual Studio .NET, consult the Microsoft Visual Studio .NET compiler documentation.

Results

For more information on common errors related to .NET CLR routine creation and invocation, see: