How to call COBOL from C# interface


Please let me know how to call COBOL program(API created in COBOL) in my C# interface with out changing original code.



  • Hi Manasa,

    If you are referring to calling a procedural COBOL program that uses a linkage section to pass parameters directly from C# then you should look into using the ilsmartlinkage directive.

    An example can be found in the docs here:

    There is also an example under the Samples Browser, select COBOL Book in the left hand pane and then C# WinBook in the right hand pane.


  • Hello Sir,

    Thank you very much for the reply.

    In my scenario I have to do below jobs.

    1. Call Cobol program(Call Linkage  section parameter) from COBOL API)

    2. Enable that API in my C# interface.

    Please guide me on below questions.

    1. Is calling linkage section parameter enables API or I need to add separate functionality to enable cobol API.

    2. Enabling API in C# from passing parameters is different then please guide me how to enable API (API created in COBOL) in C#.

    We are using Raincode legacy program to convert from Mainframe to .NET.

    Am very much new to this COBOL and I have basic knowledge of C#. Please guide me.


  • Hi,

    I referred the Docs link which provided. Below statement is there in summary page:

    •In the non-COBOL project, add a reference to the COBOL project and the MicroFocus.Runtime.Assembly

    As per above statement I need to add "MicroFocus.Runtime.Assembly" in my C# interface reference. But what reference I need to add to COBOL project as I have not involved in COBOL programming.

    Please guide me.



  • Hi,

    I don't have access to sample browser as I have not installed software. If possible, please provide any sample example of calling cobol parameters in C# interface (linkage section).

    Any example application with the code is great help to me.

  • You must have access to the Visual COBOL software in order to create this properly as the COBOL programs must be compiled as managed code using the ilsmartlinkage directive.

    How are the COBOL programs that you are attempting to call from C# delivered to you? Do you have access to the source code or are you just provided with an executable such as a .dll?

    Is the COBOL piece compiled with Visual COBOL? Is it unmanaged code or managed .NET code?