Skip to main content

Problem:

In Net Express with .Net version 5.0 a CALL “MethodName” could be used to call a static method. When the method is defined in the same project, it still works unchanged with Net Express 5.1. When the called method has been placed in a different project, compiling this code in Net Express 5.1 results in:

warning COBCH0987: Could not find method 'METHODENNAME' with this signature - will generate dynamic call.

Executing the program gives the message: RTE 173: Program not found.

Resolution:

It is not recommended to CALL a method. An INVOKE is the correct way to start a method. There might be existing programs which CALL methods, and for these programs there is a way doing it in Net Express 5.1:

A change can be made in the CALL allowing a dynamic CALL to unmanaged code, for example, CALL VariableName, which disallows the old behavior at CALL “MethodName”.

The following steps are necessary for static COBOL methods to be callable:


  1. Define the custom-attribute "MicroFocus.COBOL.RuntimeServices.CallableAttribute" for the method, the class, and the assembly:
    • environment division.
    • class-attributes.
    • custom-attribute is type
    • "MicroFocus.COBOL.RuntimeServices.CallableAttribute".
    • assembly-attributes.
    • custom-attribute is type
    • "MicroFocus.COBOL.RuntimeServices.CallableAttribute".
    • method-id. "MyStaticMethod"
    • custom-attribute is type
    • "MicroFocus.COBOL.RuntimeServices.CallableAttribute".
  2. Add the following references in the project where the method is defined:
    • MicroFocus COBOL Runtime
    • MicroFocus COBOL RuntimeServices

Read the Micro Focus COBOL .Net help "Makes non-COBOL static methods callable from COBOL with the verb CALL" at: ms-help://MF.NXNET.2008/RuntimeServices/rhrtsv37.htm.

Note: This also applies for COBOL programs.

Incident Number: 2278328

Old KB# 14490