Using the ACUCOBOL-GT COM Server

An alternate way to provide COBOL services to a .NET assembly is through the ACUCOBOL-GT COM server.

The COM server is a COM object containing the ACUCOBOL-GT Windows runtime DLL. It provides a COM interface between the ACUCOBOL-GT runtime and programs running outside the runtime. For more information on the COM server, see Using the ACUCOBOL-GT COM Server.

When the COM server is added to a .NET project, .NET creates a proxy object, "Interop.AcuGTObjects.dll", that provides an interface between .NET and the ACUCOBOL-GT COM server object. The .NET proxy gathers data intended for use by the COBOL program and packages it in COM variant formats before sending it to the ACUCOBOL-GT COM server. This process is known as data marshalling. The COBOL program uses C$GETVARIANT and C$SETVARIANT to retrieve and update data held by the ACUCOBOL-GT COM server object. The proxy also unmarshals data received from ACUCOBOL-GT COM server before delivering it back to the .NET program. The proxy is designed to manage the interchange between the .NET and COBOL worlds.

Invoke an ACUCOBOL-GT program from a .NET assembly as follows:

  1. Install and register the ACUCOBOL-GT COM server on the system running .NET. Install the COBOL object file there as well. Instructions are provided in Using the ACUCOBOL-GT COM Server.

    Once the COM server is registered on the .NET system, the ACUCOBOL-GT runtime is then exposed to any program running in that environment.

  2. To use the ACUCOBOL-GT COM Server, select a .NET application that requires the ACUCOBOL-GT interface. (The ...\sample\dotnet\NetToAcuCobol directory contains a sample that you can use.)
    1. In Visual Studio .NET, right-click the project name in the Solution Explorer window to display a selection menu.
    2. Select Add Reference from the resulting pop-up menu to display the Add Reference dialog box.
    3. Select the COM tab from the Add Reference dialog box.
    4. Select ACUCOBOL-GT 8.0 Type Library (Acugt.tlb) from the list and click OK.

    Visual Studio generates a .NET proxy module to interface with your COM object identified as "Interop.AcuGTObjects.dll".


    Visual Studio .NET Add Reference dialog box

  3. Add the proxy interface to the .NET application source. For example, if you are using Visual Basic or C#, you would add the following:

    Visual Basic:

    Dim AcugtInterface As Object 
    AcugtInterface = New AcuGTObjects.AcuGTClass 

    C#:

    AcuGTObjects.AcuGTClass AcugtInterface = new  AcuGTObjects.AcuGTClass(); 
  4. Run the .NET service and it will invoke the COBOL program as necessary.
    Note:

    The ...\sample\dotnet\NetToAcuCobol directory contains a "ReadMe.txt" file that describes using the example with the "AcuGTObjects.AcuGTClass".