Data Marshaling and Type Conversion for Managed Code Interoperation
Data type compatibility is one of the main issues when managed COBOL interoperates with code in non-COBOL managed languages. Often, you need to manipulate the COBOL data into compatible types.
Type Compatibility in Interoperation with Managed Code
For COBOL to interoperate with managed code in other languages, the COBOL must use data types that are compatible with those languages. Often there is not a strict one-to-one correspondence between types in different languages and so you need to manipulate the code to ensure compatibility.
Exposing COBOL Linkage Data as Managed Types
You can expose the COBOL linkage section and entry points to other managed languages by compiling with the ILSMARTLINKAGE directive.
Write a Proxy or Edit the COBOL for Managed Interoperation?
If the COBOL types are incompatible with the managed non-COBOL you want to interoperate with, you can either re-engineer the existing COBOL, or write a proxy COBOL class to act as an interface between the existing COBOL and the non-COBOL.
Examples of Compatible Types for Native and Managed COBOL
The InterfacingWithStdCOBOL.sln solution contains six projects. There are three pairs of projects, where each pair comprises a C# client console project and a COBOL project. Each client C# project makes a reference to its corresponding COBOL project so that it can use the implicit or explicit COBOL methods that are exposed.