Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

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

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

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.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-04-25 20:59
Updated by:
 
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.