Skip to main content
Question

COBOL .NET Call programs in a different folder

  • January 13, 2026
  • 4 replies
  • 60 views

Neil Hayes
Forum|alt.badge.img+1

This pertains to the use of external filehandlers, where my COBOL class is compiled with CALLFH"abcdef", which in tern needs to call fh/aaaaaa.dll which exists in the sub folder fh.

The COBOL has :

CALL “fh/aaaaaa” using ………

During animation I debug the class, debug abcdef, but when it gets to the CALL “fh/aaaaaa” it doesn’t raise an exception but doesn’t execute the code either.

I can see from procmon that the assembly was indeed loaded as well as the .pdb but just ignored almost as though it was looking for the programid but that didn’t match.

Is this not supported?
Is there an COBOL .NET  replacement for COBPATH ?

Neil

 

4 replies

Chris Glazier
Forum|alt.badge.img+3

Hi Neil,

Is the entry point of the program name you are calling the same name as the dll name?

If the assembly aaaaaa.dll is within the system PATH then it should be found with:

call “aaaaaa”

You could also set a procedure-pointer to load the .dll prior to the call:

01 pp procedure-pointer.

      set pp to entry “fh\aaaaaa.dll”

      call “aaaaaa”

 

 


Peter Restorick
Forum|alt.badge.img+2

Hi Chris,

I’m working through this for Neil as part of our conversion and have found that setting the process PATH variable does work but the overhead is quite significant even if the folders are at the beginning of the variable - using procmon I can see that it probes a number of folders.

So I am looking at the use of the procedure-pointer in your example above but ignorance is bliss regarding procedure pointers and how they work.

  1. Is a procedure pointer required for each and every dll that is called in this manner or can I use a common procedure-pointer for all calls?
  2. Must the procedure pointer be set prior to every call or must it only be done the first time a program is called?

Regards

Peter


Chris Glazier
Forum|alt.badge.img+3

Hi Peter,

You can reuse the procedure-pointer variable because it just causes a load of the .dll. If you know where your .dll is located, you can also you a full path name in the procedure-pointer entry name, to keep it from searching the PATH. The .dlls only need to be loaded once and not before each call.

An easier way than using a procedure-pointer, if you have a large number of .dlls is to add then to the preload section of an app.config file for your main program. Again, the names can be specified without a path in which case PATH will be searched or you can specify a full path name: Take a look at: Calling Entry Points in Subprograms

Example

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="MicroFocus.COBOL.Application">
<section name="Switches"
type="System.Configuration.NameValueSectionHandler" />
<section name="Environment"
type="System.Configuration.NameValueSectionHandler" />
<sectionGroup name="Interop">
<section name="PreLoad"
type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</sectionGroup>
<!--The following code declares a section group for
run-time configuration -->
<sectionGroup name="MicroFocus.COBOL.Runtime">
<section name="Tunables"
type="System.Configuration.NameValueSectionHandler" />
<section name="Switches"
type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>

<MicroFocus.COBOL.Application>
<Switches></Switches>
<Environment></Environment>
<Interop>
<PreLoad>
<add key="subprog1.dll" value="managed" />
<add key="C:\tests\testdllload\subprog2\bin\Debug\net8.0\subprog2.dll" value="managed" />
</PreLoad>
</Interop>
</MicroFocus.COBOL.Application>
</configuration>

 


Peter Restorick
Forum|alt.badge.img+2

This is good news thanks Chris - I will definitely look at the preload option as we are already doing something similar for entities that are being invoked in context