Print Page | Close Window

32 bit Debenu DLL loding on 64 bit machine

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3623
Printed Date: 26 Nov 24 at 4:09AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: 32 bit Debenu DLL loding on 64 bit machine
Posted By: kumarp11
Subject: 32 bit Debenu DLL loding on 64 bit machine
Date Posted: 25 Oct 18 at 11:29PM
Hello,
I am using the below code to load the proper DLL in my application but I am sometimes noticing that 32 bit Debenu DLL loading on 64 bit widows operating system. Why it is happening and does it cause any issue while printing?


PDFLibrary quickPdf = null;
                        if (IntPtr.Size == 8)
                        {
                            quickPdf = new PDFLibrary(DllPath64Bit);
                        }
                        else
                        {
                            quickPdf = new PDFLibrary(DllPath32Bit);
                        }
                    quickPdf.UnlockKey(key);



Replies:
Posted By: Wheeley
Date Posted: 26 Oct 18 at 12:55AM
Just because your OS is 64-bit doesn't mean you should use a 64-bit dll. You should only use a 64-bit DLL if you program is compiled as a 64-bit application, otherwise tehe 32-bit should be used. So how are you compiling your code? 32-bit or 64-bit?


Posted By: Ingo
Date Posted: 26 Oct 18 at 7:37PM
Some more common words regarding 32-/64-bit...
If you're using a 64 bit dll then you can use it only in 64 bit environments. On 64 bit systems the dll should be in the system32-directory: On 64 bit systems this directory (irritating name!) is used only for 64 bit dlls. If you're using a 32 bit dll it should be in the SysWOW64-directory on 64-bit-environments.
If you're working with a 64 bit development and a 64 bit dll you may need to set your compiler platform target to "Any CPU” to create a 64 bit EXE instead of "x86" to force it to create a 32 bit EXE. Application and dll should have the same architecture – both 32- or both 64 bit.


-------------
Cheers,
Ingo



Posted By: kumarp11
Date Posted: 26 Oct 18 at 9:49PM
Actually, we have customers using a mix of environments, 32 bit machines and 64 bit machines(WIN 10,8 and Win 7). We want Debenu 32 bit dll to load on 32 bit machines(OS) and 64 bit dll to load on 64 bit machines(OS). We are using this code to determine which DLL to load but sometimes we are seeing 32 bit dll getting loaded on 64 bit machines. I did some investigation and found that if IntPtr.Size is 8 then it indicates 64 bit environment and using this code accordingly to load debenu dll.

 PDFLibrary quickPdf = null;
                        if (IntPtr.Size == 8)
                        {
                            quickPdf = new PDFLibrary(DllPath64Bit);
                        }
                        else
                        {
                            quickPdf = new PDFLibrary(DllPath32Bit);
                        }
                    quickPdf.UnlockKey(key);

are we doing something wrong?


Posted By: tfrost
Date Posted: 27 Oct 18 at 10:22AM
Probably.  IntPtr.Size will depend on whether the program calling the DLL is built as a 32-bit or 64-bit program, which is a compiler setting.  If you build your application to run as a 32-bit process, the pointer size will not change if you run this program on a 64-bit operating system, the pointer size it uses will not change and it will still require a 32-bit DLL.

The key rule to remember is that a 32-bit DLL cannot be called by a 64-bit process, and vice-versa.

You can test whether the environment running your 32-bit process is 64-bit by various means (Google will help you).  I load kernel32.dll without a path and see if it contains an entrypoint named GetSystemWow64Directory, but there are plenty of other means. The answer will not change the pointer size used by the compiler, or which DLL your program needs to load.


Posted By: tfrost
Date Posted: 27 Oct 18 at 10:28AM
I should add: if you are seeing a 32-bit DLL successfully loaded on a 64-bit OS, this tells you that the 64-bit OS is running a 32-bit version of your application.  And if you see a 64-bit DLL successfully loaded, a 64-bit version of your application.  In the first case, your user has simply managed to choose the 32-bit version somehow, if you deliver both.


Posted By: Ingo
Date Posted: 28 Oct 18 at 1:47PM
Hi,

"...We are using this code to determine which DLL to load...".

If this code is running on your single app this will never work.
A 64 bit app needs a 64 bit dll and a 32 bit app needs a 32 bit dll.
The app and the functions inside a dll needs the same bit-architecture for proper working.



-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk