Running External DLL on Server

newguy

Member
First of all, allow me to thank everybody on this group for providing valuable information on custom development. Special thanks to "WhippingBoy" for his knowledge on http://www.ocode.net

With that said, I wrote a C business function (B55001) that calls an external dll, which I placed in my <pathcode>/bin32 directory. This BSFN seems to work fine on a fat client. However, when I tried to map the bsfn to the server, it just seems to hang and does not seem to work. I placed the DLL in the <pathcode>/bin32 directory on the enterprise server, and then used OCM to map to the enterprise server. I checked the "Environment Path" on the enterprise server to make sure it is pointing to the right path.

I know that there may be problems with running these DLLs on the server, but since its also a windows machine, I can't understand why it wouldn't work....
Any help would be greatly appreciated!!!

I'm running on Win2k workstations and Win2k server, on SQL server.

Thanks!!!
--Jim
 
Hi there,

Be sure to compile your BSFN on the Enterprise Server (server
package). You can't just copy and paste a DLL from a client and
paste it on the server, even if the latter is an Intel Windows box.
Both Server and Client DLLs are generated with different C
compiler switches, thus they're not compatible.

Sebastian Sajaroff
 
I experienced a similar problem back with version B7332, a while ago.

There was a difference in the way the binaries were created, depending if you were on the enterprise server or on a fat client. I believe that this is still the case with more recent versions.

The byte alignment is not the same on both platforms. If I am correct, the byte alignment on a fat client is 1 bit an on the enterprise server 8bits.

This has to do with how the compiler will align the variables of a structure in memory. In my case, a numerical field overlapped on a string field when the custom DLL was compiled with 1 bit structure alignment.

The solution I found (if I remembre correctly again... from a couple years ago) was to use the following compiler directive

#pragma pack x

Where x is the desired byte alignment. If x is not specified, the default alignment is used.
This directive should be placed before (with a specific alignment) and after (with no alignment) the definition of the external function's parameters structure.

Do you have the source code of the External DLL? If so, an alternative could be to compile using a different byte alignment for the version that will run on the server.

Good luck, and keep us posted with your results.
 
Thank you for the quick responses. The problem was, in fact, the byte alignment. There was also another post in this forum titled "Custom DLL" that also seemed to describe a similar scenario. The big problem I had, was figuring out where to put the external DLL. But I also fixed it by putting it in the <pathcode>\bin32 directory. Fortunately the externa DLL I was interacting with, was able to be recompiled. THANK YOU!
--Jim
 
I am glad I could help.

This is not a well known fact...

If you can't recompile an external DLL, you can try the #pragma pack approach.

In order to simplify the deployment process, I usually map the external function calls to the enterprise server.
 
Back
Top