Print Page | Close Window

How to use DebenuPDFLibrary64DLL0915.DLL on .NET

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2700
Printed Date: 25 Nov 24 at 8:06PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to use DebenuPDFLibrary64DLL0915.DLL on .NET
Posted By: eranga
Subject: How to use DebenuPDFLibrary64DLL0915.DLL on .NET
Date Posted: 05 Aug 13 at 2:18AM
Hi,

Can someone please shed some light on how to use the DebenuPDFLibrary64DLL0915.DLL? I've tried the sample on the website but that does not work and it may be partly because the sample was using the 32bit version of the DLL. I've already done below

1. Installed the Debenu Quick PDF Library 9 Trial (i.e. its the EXE which runs an installer and create "Debenu Quick PDF Library" link on the desktop
2. Downloaded the .net sample from below link and followed the instructions but failed to compile the program
http://www.debenu.com/downloads/code-samples/dpl/visual-basic_net_dll_sample.zip
Note: I'm using VS 2012 and .NET 4.5

I tried below code

QP = New PDFLibrary("DebenuPDFLibrary64DLL0915.dll") 'DLL is in C:\Windows\SysWOW64 
'Insert your trial or commercial license key here 
Result = QP.LibraryLoaded()
If Result = False Then
     MsgBox("- DLL not loaded -")
End If

I'm getting DLL not loaded

I cannot directly reference DebenuPDFLibrary64DLL0915.DLL and also the DLL already available on Reference manager COM Library "Debenu Quick PDF Library 9.1.5 does not also seems to work

What could be the reason? Is there a specific way to link this DLL to the app? Your prompt response is greatly appreciated. Thanks

Best Regards,
Eranga



Replies:
Posted By: Ingo
Date Posted: 05 Aug 13 at 6:44PM
Hi Erenga!

That's wrong!
The 64-bit-dll should be in the system32 (yes!)
and the 32-bit-dll should be in syswow64.
It's hard to understand Microsoft but it's so ;-)

Cheers and welcome here, 
Ingo


Posted By: AndrewC
Date Posted: 06 Aug 13 at 4:18AM
Here is some sample C# code showing how to use the library.  It assumes that the DLL's are in the same directory as the EXE file or that the DLL's are copied into the Windows directory as indicated.

This code will automatically load the correct DLL based on the project configuration and the currently running CPU mode.  ie 32 or 64bit mode.

Note also : The DebenuPDFLibrary...DLL is a Win32 DLL and not a .NET DLL so it cannot be added to the Project as a DLL in the same way that a .NET DLL can.  You only need to add the DebenuPDFLibraryDLL0915.cs or .vb file to your project as an existing item.  These import files can be found in the <DQPL install dir>\DLL\Import\CSharp or <DQPL install dir>\DLL\Import\VB.Net directories as required.

using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

using DebenuPDFLibraryDLL0915;

namespace QPLToolbox
{
    public partial class Form1 : Form
    {
        PDFLibrary QP;

        public Form1()
        {
            InitializeComponent();

            string dllName;
            if (IntPtr.Size == 4)
                dllName = "DebenuPDFLibraryDLL0915.DLL";    // 32 bits  - \Windows\SysWOW65
            else
                dllName = "DebenuPDFLibrary64DLL0915.DLL";  // 34 bits - \Windows\System32

            QP = new PDFLibrary(dllName);
            if (QP.LibraryVersion() == "")
                MessageBox.Show("QPL DLL - " + dllName + " - Not loaded");

            bool b = QP.LibraryLoaded();

            if (QP.UnlockKey("<insert your key here>") == 0)
                MessageBox.Show("QP.UnlockKey failed");

            if (QP.Unlocked() != 1)
                MessageBox.Show("QP.UnlockKey failed");
        }
        ...
        ...


Posted By: eranga
Date Posted: 06 Aug 13 at 6:58AM
Thanks for the replies. I've tried what You have asked but still it does not seems to work (i.e. still get the message "- DLL not loaded -". Below is my code
I've also copied DebenuPDFLibrary64DLL0915.dll to C:\Windows\System32\
I already had DebenuPDFLibraryDLL0915.vb included as a file on the project

Imports System
Imports System.Collections
Imports System.Data
Imports System.Diagnostics
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Imports visual_basic_dll_sample.DebenuPDFLibraryDLL0915 ' The DebenuPDFLibraryDLL0915.vb import file must be added to the project

Public Class Form1

    Dim QP As PDFLibrary
    Dim qp1 As Integer

    Dim LicenseKey = "SOMECODE--not the actual code" ' Insert your trial or commercial license key here

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        test1()
    End Sub

    Private Sub test1()
        Dim QP As PDFLibrary
        Dim Result

        'Update path to DLL if necessary
        QP = New PDFLibrary("DebenuPDFLibrary64DLL0915.dll") 'DLL is in C:\Windows\SysWOW64 

        'Insert your trial or commercial license key here 
        Result = QP.LibraryLoaded()
        If Result = False Then
            MsgBox("- DLL not loaded -")
        End If
        Result = QP.UnlockKey(LicenseKey)
    End Sub

End Class


Posted By: darkv
Date Posted: 06 Aug 13 at 9:53AM
Eranga,

when you invoke the New pdflib(debenu....dll), could you try to refer to the dll fullpath.

I know that VS, sometimes does not use the system path variable (especially in debug mode)

Rgds



-------------
z Dark side is there ...


Posted By: eranga
Date Posted: 07 Aug 13 at 1:09AM
Hi Darkv,
I did try the full path (i.e. C:\Users\eranga.imaduwa\Documents\Visual Studio 2012\Projects\TestDebenuQuickPDF\DebenuPDFLibrary64DLL0915.dll) but still it does not work. I think there is something wrong with the initial setup of the module. Can you or someone please tell me how to confirm if the installation was complete (Please note that I need to use the 64 bit version DLL therefore please provide instructions related to 64 bit version DLL as well). 

Thanks
Eranga


Posted By: AndrewC
Date Posted: 07 Aug 13 at 5:37AM
Eranga,

In VS under the Build Menu there is an option callled Configuration Manager.  You need to make sure that the active solution platform is set to x64 and not to x86.  ie.  You need to make sure that the project is actually creating a 64 bit DLL.  If it is set to AnyCPU then I suggest to change it to x64 to force it to compile in 64bit mode.

To change from AnyCPU, go to Build, Configuration Manager option in the main menu.  Click on the Platform dropdown in the 'Project contexts' list and choose New, choose x64 as the new platform and copy the settings from AnyCPU and press OK.  You will find that your project now runs correctly.

I have tested the following code with VS 2012 using  VB.NET 4.5 and it required the AnyCPU change to x64 to make it work correctly.

' --------------------------------------------------------------------------------------------------------------------------

Imports System
Imports System.Collections
Imports System.Data
Imports System.Diagnostics
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Imports WindowsApplication1.DebenuPDFLibraryDLL0915 ' The DebenuPDFLibraryDLL0915.vb import file must be added to the project

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim QP As PDFLibrary
        Dim Result
        Dim LicenseKey

        LicenseKey = "<insert your key here>"

        'Update path to DLL if necessary
        QP = New PDFLibrary("DebenuPDFLibrary64DLL0915.dll") 'DLL is in C:\Windows\System32 

        'Insert your trial or commercial license key here 
        Result = QP.LibraryLoaded()
        If Result = False Then
            MsgBox("- DLL not loaded -")
        Else
            MsgBox("DLL loaded correctly")
        End If

        Result = QP.UnlockKey(LicenseKey)

        If Result = False Then
            MsgBox("- DLL not Unlocked -")
        Else
            MsgBox("DLL Unlocked")
        End If
    End Sub

End Class

' --------------------------------------------------------------------------------------------------------------------------

In the 64bit mode you should be placing the DLL into \Windows\System32 and not into SysWow64 as Ingo correctly points out.  It doesn't seem logical but that is how Microsoft designed it.

The safest option is to specify the full path to the DLL or to place the DLL into the same directory as the EXE file.  In VS this will need to be in the Debug or Release subdirectory of your project directory.

Andrew.


Posted By: eranga
Date Posted: 07 Aug 13 at 6:02AM
Thanks Andrew. Finally its working now Smile



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