I would like to be able to use our 32-bit installation of ACUCOBOL 9.2.1 to call a method from a non-GUI class in a .NET 4.0 DLL.
There are no sample programs in the sample directory that show an example of using the CREATE statement, so I tried to write my own. However, I can't get the COBOL in my minimal test to compile. Can anyone here help?
The C# code for the .NET DLL is in the file MyDLL.cs:
namespace MyNamespace {
public class MyClass {
public int getInt() {
return 42;
}
}
}
I compiled this in 64-bit Windows 7 using what I think is the "any CPU" version of the C# compiler and framework:
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc /t:library MyDLL.cs
The resulting DLL is named MyDLL.dll. I then used the 32-bit version of netdefgen to create a copybook called MyDLL.def:
* ACUCOBOL-GT Version 9.2.1 .NET Copy Book - Generated On 10/10/2013 2:52:07 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] Int32 getInt()
METHOD, 0, "@getInt"
RETURNING "int", TYPE 3
The COBOL for the test program (MyCOBOL.cbl) 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.
INQUIRE WS-NONGUI-HANDLE "getInt" IN WS-INT
DISPLAY "WS-INT: " WS-INT
ACCEPT OMITTED
GOBACK.
All of the files above are in the same directory:
C:\\Some\\Working\\Directory>dir /b
MyDLL.cs
MyDll.def
MyDLL.dll
MyCOBOL.cbl
I compiled the COBOL using :
%PATH_TO_32BIT_ACU921%\\bin\\ccbl32 -Sp . MyCOBOL.cbl
The errors are:
MyCOBOL.cbl, line 21: 'getInt' must be a 'get' property or method of 'MyNamespac
e'
MyCOBOL.cbl, line 21: Verb expected, IN found
This doesn't make a whole lot of sense. I would have expected the compiler to look for a method of 'MyClass' rather than 'MyNamespace'.
What am I doing wrong?
#compilererrors
#.net