I have a problem with my web application making calls to PXCLIB40.dll when running in 64 bit development environment
I'm having trouble getting my app to make calls into PXCLIB40.dll when running in a 64bit development environment.
When I use the 64bit version of pxclib40 I get a "BadImageFormatException" and trying the 32bit version consistently gives a "DllNotFoundException" even though both files are placed in the same directory (not at the same time). I have tried changing the target processor type to 32 & 64bit to see if that would make a difference, but it did not.
This is happening in a ASP.Net web application, using C# to call into the dll. I am using VS 2008.
PXCLIB40 is version 4.0.160
My app and the call into the dll work just fine on a 32bit OS using the 32bit version of pxclib40.
Possible Causes and Resolutions
Ensure that you are using all the dependant 64 bit DLL's - not just the 64 bit release of pxclib40.
- e.g. : fm40base.dll, fm40tiff.dll, xcpro40.dll etc (see the help file/pdf manual for the full list)
A problem exists in the .NET platform specifically - by default all projects use "Any CPU" settings, which means that, on a 32-bit OS, the program will be 32-bit (and use 32 bit DLLs), and on a 64-bit OS, the same program will be 64-bit (and use 64-bit DLLs).p
Of course all DLLs must be 32/64-bit correspondingly, not only PXCLIB40.dll (you should have 32-bit set and 64-bit set, but do not mix them).
And now you have three variants:
- Use "Any CPU" setting, and depending on the OS copy 32-bit or 64-bit dll set to program folder.
- Always use x86 settings (your program always will be 32-bit) and use the 32-bit dll set.
- Create two versions of your program - x86 (32-bit) and x64, and use the corresponding dll set.
Here is full list of required and optional DLLs:
- xcpro40.dll - main dll, required.
- xccdx40.dll, pxclib40.dll, ixclib40.dll, dscrt40.dll - required as xcpro40 depends on them.
- fm40tiff.dll - optional, add tiff image format support when dealing with image files.
- fm40base.dll - optional, add PNG,JPEG,GIF,PCX,TGA and some other image formats.
- other fm40*.dlls must be removed (since ixclib40 will try to load them and this may cause exception in some environments).
If one of these .dlls is 32-bit when another is 64-bit (or vice versa) you will get an error.
Visual Studio WebDev.WebServer.exe
The reason for the BadImageFormatException is that Visual Studio by default runs a 32-bit "WebDev.WebServer.exe" which cannot load a 64-bit ASP.NET application.
More Like This
- KB#72: How do Icopy an image from an existing PDF file to a new PDF file and retain the original dimensions?
- KB#227: I have an issue using the PDF-XChange SDK sample code with Microsoft Visual Basic in 'Interactive Mode' for debugging.
- KB#50: Error when running application scheduled task
- KB#51: I have a problem with my web application making calls to PXCLIB40.dll when running in 64 bit development environment
- KB#118: Can I use the PDF-XChange print driver from Delphi 5 to save a Quick Report as a PDF file without user intervention?