Program calling FHREDIR directly reports invalid format error if target is AnyCPU

0 Likes
over 7 years ago

Problem:

Customer has a managed .NET application that calls the external file handler directly through fileshare by doing:
     CALL "FHREDIR" ...
This works fine when compiled to a target platform of x86 or x64 but when the platform is set to AnyCPU the program will report an invalid format exception error when the CALL statement is executed.

Why does this occur and is there a workaround for this?

Resolution:

The problem is that the FHREDIR assembly does a p/invoke to call in the required native code CCI modules.

The CCITCP.dll (or anything that is platform invoked) is loaded from the system PATH. So, if the project is AnyCPU and is executed on a 64-bit machine then you would need to run it from a 64-bit Visual COBOL command prompt or at least make sure all the required 64-bit native DLLs (ccitcp.dll and mfcrptlib.dll in this case) are on the PATH or in the current directory.

The 64-bit versions of these files are found in the folder: C:\Program Files (x86)\Micro Focus\Visual COBOL for Visual Studio 2012\bin64

This either has to be first in the path or you can copy the two files mentioned above to your output folder.

On a 32-bit machine you will have to use the 32-bit version of these .dlls.

Comment List
Anonymous
Related Discussions
Recommended