Link to home
Start Free TrialLog in
Avatar of psyche6
psyche6

asked on

Running a 32 bit DLL product in Windows 2008 64 bit

I have built a (strongly named) .Net library that uses a 3rd party tool, pdf2image. This 3rd party tool is supplied as a old type (pre-com) windows dll (something I almost understand). Please see the sample .Net declaration and call in the Code section. This all works fine on a Windows 2003 32 bit machine.

When I tried to move this library to a Window 2008 64 bit server, the call to 3rd party tool fails, almost certainly because it is a 32 bit dll (the .Net code itself runs fine until it gets to this call). I've heard of a 32 bit compatability mode on 64 bit machines, but all of the discussions focus on running 32 bit programs (EXEs) rather than accessing legacy libraries (DLLs).

Is there any way to make this 3rd party tool dll work on a 64 bit machine?

[DllImport(@"C:\bin\pdf2image.dll", CharSet = CharSet.Auto)]
        static extern uint PDFToImageConverter(
            [MarshalAs(UnmanagedType.LPStr)] string FileName,
            [MarshalAs(UnmanagedType.LPStr)] string OutputName,
            IntPtr UserPassword, IntPtr OwnPassword,
            int xresolution, int yresolution, int bitcount,
            int compression, int quality, int grayscale,
            int multipage, int firstPage, int lastPage);
 
                result = PDFToImageConverter(FileIn, _FileOut, UserPassword, OwnPassword, 300, 300, 1,
                    COMPRESSION_LZW, 70, FALSE, TRUE, -1, -1);

Open in new window

Avatar of graye
graye
Flag of United States of America image

There is an easy fix....    just recompile your application to target the "x86" CPU rather than the default of "AnyCPU".   That will force your application to run in the 32-bit mode on a 64-bit (which in turn, allows the 32-bit 3rd-party DLL to load).
From the menu, select Project, then Properties.  Select the Build vertical tab, and change the "Platform Target" to x86
Avatar of psyche6
psyche6

ASKER

Thanks for the great response! I'm probably almost there. One thing that I should have mentioned is that my .Net library (ResultReports.dll) that uses the 3rd party library (pdf2image.dll), is in turn used by an ASP.Net application.

I can recompile my library, ResultReports, to target x86 and then publish it to the GAC on all of our 32 bit web servers and it works fine. When I publish the recomplied library to our new Windows Server 2008 64 bit web server, the ASP.Net web application throws this error:

Could not load file or assembly 'ResultReports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c92e9103e2573633' or one of its dependencies. The system cannot find the file specified. (C:\OnlineResultsMRO\web.config line 101)

Note: the published web application was simply copied to the new 64 bit server ahd has worked OK except for this problem. It's built in Visual Studio 2005 and targets the Framework v2.0

Apparently, ASP.Net web applications on a 64 bit machine don't like assemblies in the GAC that target x86. Is there a was around this? If not, I may just run IIS in a virtual x86 server hosted by the 64 bit server.

Thanks again.
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of psyche6

ASKER

Thank you so much!