Solved

Running a 32 bit DLL product in Windows 2008 64 bit

Posted on 2009-03-30
4
2,995 Views
Last Modified: 2013-11-29
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

0
Comment
Question by:psyche6
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:graye
ID: 24029841
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
0
 
LVL 1

Author Comment

by:psyche6
ID: 24030724
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.
0
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 24034549
That's correct... in no circumstances can you configure a 64-bit applicaiton to run with a 32-bit DLL...  it's just not gonna happen
So, again, the solution is fairly easy... you just configure IIS to run the the "32-bit emulation mode".   Windows 2008 allows you configure the 32-bit emulation separately for each "application pool".   Note:  For the previous version (ie. Windows Server 2003) the conversion to the the 32-bit emulation mode was an "all or nothing" proposition... not so with Windows Server 2008.  That means  you won't have to convert all of you web applications to 32-bit... you can just convert this one.
http://learn.iis.net/page.aspx/201/32-bit-mode-worker-processes/ 
0
 
LVL 1

Author Closing Comment

by:psyche6
ID: 31564611
Thank you so much!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now