sebastian_braun Contributor.
Contributor.
281 views

Execute Cobol Code in C# Applications

Hi together,

I'm trying to make a new C# Application and execute existing Cobol Code. My problem now is:

If i create a Cobol solution in Visual Studio and 

  • set the Output type to "Link Library", i can compile it to a .dll file, but couldn't add this file as a reference in my C# solution.
    • Error: Make sure that the file is accessible and is a valid Assembly or COM-Component
  • - set the Output type to "Class Library", i get lot of Errors. For example:
    • Error: COBCH0860 Object references must be specified at 01 level ...
    • Unknwown types; Redefines on incorrect field; Not a data name ...

Does anyone know how i can compile existing code files and import it to my new Application or fix my Problems above?

0 Likes
4 Replies
Micro Focus Expert
Micro Focus Expert

Re: Execute Cobol Code in C# Applications

You need to select the Class Library project template from the managed code category. The Link Library template is for native .dlls and the Class Library template will generate a .NET assembly with a .dll extension. You can then add the COBOL project as a reference to the C# project.

0 Likes
sebastian_braun Contributor.
Contributor.

Re: Execute Cobol Code in C# Applications

And do you know how i could avoid the Problems above (f.e. Object references must be specified at 01 level ...)?
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute Cobol Code in C# Applications

Sorry I must have missed this part of your first message.

If this is an existing native application that uses the native OO syntax and class libraries then you are not going to be able to compile it as managed code as they are not compatible.

Is this a Dialog System application by any chance?

0 Likes
sebastian_braun Contributor.
Contributor.

Re: Execute Cobol Code in C# Applications

Hi Chris,

thanks so far for your quick responses.

No this isn't a Dialog System application. Our system uses direct winapi calls with the apigui classes from Netexpress.

So now we are looking for a solution to combine our native code with managed code. Do you know, how we can implement this? Or if there are documentation?

Regards Sebastian

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.