"Invalid class string" error on MODIFY statement

Using 32-bit ACUCOBOL 9.2.1 in Windows 7, I get the following error when executing a MODIFY statement:

---------------------------
Error
---------------------------
Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
COBOL error at 00002C in MyCOBOL.acu
("MyCOBOL.cbl", line 22)
---------------------------
OK
---------------------------

The MODIFY statement is:

           MODIFY WS-NONGUI-HANDLE "getInt"() GIVING WS-INT

The complete COBOL code is:

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  TESTPROG.

       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           COPY "MyDLL.def".
           .

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77  WS-NONGUI-HANDLE  HANDLE OF "@MyDll.MyNamespace.MyClass".
       77  WS-INT            PIC 9(5).

       PROCEDURE DIVISION.
           CREATE "@MyDLL"
             NAMESPACE IS "MyNamespace"
             CLASS-NAME IS "MyClass"
             HANDLE IS WS-NONGUI-HANDLE.

           MODIFY WS-NONGUI-HANDLE "getInt"() GIVING WS-INT
           DISPLAY "WS-INT: " WS-INT
           ACCEPT OMITTED
           
           GOBACK.

I saw in a previous forum post that this error can occur if AcuToNet.dll is not registered. Since I used the .NET 4.0 compiler when building my DLL, I assumed that the relevant utility for registering the DLL is RegAsm40Acu.exe. I therefore ran the following command in the directory containing AcuToNet.dll:

RegAsm40Acu.exe /register /codebase AcuToNet.dll

The result was "Types registered successfully". However, the run time error shown above still occurs when the MODIFY statement is executed.

I then saw in the Reference Manual that AcuToNet.dll is not ordinarily required in ACUCOBOL 9, but can be used by specifying the --a2n runtime option. So I tried that. I then got an error on the CREATE statement, which was:

---------------------------
Error
---------------------------
AcuToNet CoCreateInstance failed: 0x80131417

COBOL error at 00001E in MyCOBOL.acu
("MyCOBOL.cbl", line 16)
---------------------------
OK   
---------------------------

The reference manual does adress this error message, but what is says does not seem to apply to ACUCOBOL 9.2.1. Also I have already registered AcuToNet.dll, so perhaps that's not the full answer. Please advise -- and thank you in advance for any help.

  • Hoo boy. I thought the problem might be that I had previously registered the ACUCOBOL 8.x version of AcuToNet.dll. So I went to the bin directory for ACU 8.x, and executed:

    RegAsm20Acu.exe /unregister /codebase AcuToNet.dll

    Then I tried running my ACU 9.2.1 program again. The CoCreateInstance failed error no longer occurred on the CREATE statement, but once again I got the "Invalid class string" error on the MODIFY statement.

    ---------------------------

    Error

    ---------------------------

    Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

    COBOL error at 00002C in MyCOBOL.acu

    ("MyCOBOL.cbl", line 21)

    ---------------------------

    OK  

    ---------------------------

  • still no expert .. did you change getint to be a property? Think of modify as a call .. call a method or call a property .. if it is a property and more specifically a property_get then it cannot be modified .. property_put can be modified .. property_get must be inquire (inquired) I hope this helps.

  • I didn't change it to a property, but might as well try it.

    For clarity, I'll name the property MyInt. So the C# code becomes:

    namespace MyNamespace {

       public class MyClass {

           public int MyInt { get; set; }

       }

    }

    ====

    The MyDll.def file generated by netdefgen then becomes:

         *  ACUCOBOL-GT Version 9.2.1 .NET Copy Book - Generated On 10/15/2013 5:09:50 PM

         *  Managed assembly, generated by 32-bit NetDefGen.exe

              OBJECT @ASSEMBLY

              NAME    "@MyDLL"

              VERSION "0.0.0.0"

              CULTURE "neutral"

              STRONG  "null"

         * FULLY-QUALIFIED-NAME MyNamespace.MyClass, MyDLL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

         * MyNamespace.MyClass

              NAMESPACE "MyNamespace"

              CLASS     "MyClass"

              MODULE    "MyDLL.dll"

              CONSTRUCTOR, 0, @CONSTRUCTOR1

         * [Class: MyClass] MyInt

              PROPERTY_GET, 0, @MyInt

                  RETURNING, "int", TYPE 3

              PROPERTY_PUT, 0, @MyInt

                  "int (Property Value)", TYPE 3

    ====

    The COBOL code with an INQUIRE statement becomes:

          IDENTIFICATION DIVISION.

          PROGRAM-ID.  TESTPROG.

          ENVIRONMENT DIVISION.

          CONFIGURATION SECTION.

          SPECIAL-NAMES.

              COPY "MyDLL.def".

              .

          DATA DIVISION.

          WORKING-STORAGE SECTION.

          77  WS-NONGUI-HANDLE  HANDLE OF "@MyDll.MyNamespace.MyClass".

          77  WS-INT            PIC 9(5).

          PROCEDURE DIVISION.

              CREATE "@MyDLL"

                NAMESPACE IS "MyNamespace"

                CLASS-NAME IS "MyClass"

                HANDLE IS WS-NONGUI-HANDLE.

              INQUIRE WS-NONGUI-HANDLE "MyInt"() GIVING WS-INT

              DISPLAY "WS-INT: " WS-INT

              ACCEPT OMITTED

              GOBACK.

    ====

    The COBOL fails to compile. The error message from ccbl32 is:

       MyCOBOL.cbl, line 21: Verb expected, String literal found

  • I think method names should be surrounded by quotes in your COBOL code, but property names should not.

    Method:  MODIFY WS-NONGUI-HANDLE "getMyInt"() GIVING WS-INT

    Property: INQUIRE WS-NONGUI-HANDLE MyInt IN WS-INT

    Unfortunately, I have no idea why your original use of the method failed.

  • It does compile with that change to the INQUIRE statement, but then wrun32 gives the "Invalid class string" error. I'll submit an incident, and see what they say. Thanks for your assistance here.