Skip to Content
avatar image
Former Member

PB 12.6 Classic Error when calling local external function?

Hi,

I am using PB 12.6 Classic (Build 4098). I get the following error message when attempting to call a function from a DLL :

Error opening DLL library SAMPLE.DLL for external function at line 20 in function of_decrypt of object n_cst_encryption_api.

Snippet of local code for example purposes (missing some variables, etc, but they are defined appropriately in my local code):

n_cst_encryption_api lo_enc

lo_enc = CREATE n_cst_encryption_api

li_Result = lo_enc.of_decrypt(ls_source, ls_destination)

Within n_cst_encryption_api object, I have an object-level function defined as:

of_decrypt(as_in_file, as_out_file) returns int. Within it, we make the following call:

int li_rc

li_rc = MUnEncryptFile(as_in_file, as_out_file) //** This is where the error occurs

RETURN li_rc

Within n_cst_encryption_api object, I have the following local external function defined:

FUNCTION int MUnEncryptFile(string in_file, string out_file) LIBRARY "SAMPLE.DLL" ALIAS FOR "MUnEncryptFile"

The SAMPLE.DLL is registered, and the same code above works fine in our PB12.1 Classic and PB12.5 .NET versions. Is there a known issue with making external calls within this version/build of 12.6 classic? Is there a different syntax I should be using?

Any advice is appreciated.

Thanks,
Jason

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 10, 2017 at 02:21 PM

    The error "can't load" might actually be better described as "can't find".

    You did not state whether or not you are running this from within the PB IDE. If you are, then the DLL needs to reside in a folder where the IDE can see it when you run your app from the pbl's.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      John,

      Thanks for your input. I'm a little late on getting back to this post, but wanted to provide an update. We chased our tail on this for a few days dealing with a few moving targets (test environment, Win7 vs Win10, etc). The universal solution appeared to be the following:

      - Ensure the .dll is registered on the machine properly depending on 32 or 64 bit

      - The .dll we were having issues with (home grown .dll) had recently been rebuilt with Visual Studio 2013 (the prior version was 2010). This results in different c++ runtime files required for redistribution (msvcr120.dll, msvcp120.dll, etc). We were missing the msvcp120.dll. This was the culprit.

      So, simple solution, just took a lot of motions for us to eventually get there!

      Thanks again for your assistance.

      Jason

  • avatar image
    Former Member
    Mar 14, 2017 at 03:36 PM

    Hi,

    Try this :

    Check "Use 1-byte structure member alignment in external function" in Tools, System Options, General page (or set UseZp1=1 in [pb] section, pb.ini, the results are same). The effect is global with this setting changed. To make this work at runtime, please remember to deploy your pb.ini file with your application.


    Regards.
    Abdallah.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Abdallah.

      I replied to John the other day with the solution. Turns out I think it was a combination of our home-grown .dll either being registered properly / being in a location defined in the path. We were also missing one of the Visual Studio 2013 redistribution files (msvcp120.dll).

      Thanks,

      Jason