PDFiumSharp icon indicating copy to clipboard operation
PDFiumSharp copied to clipboard

Unable to load DLL 'pdfium_x64'

Open tmutton opened this issue 5 years ago • 8 comments

I am running into the following exception:

System.DllNotFoundException: 'Unable to load DLL 'pdfium_x64' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

When running PDFiumSharp in a dotnet core 2.2 web app. This error has been replicated in this project here https://github.com/tmutton/PdfiumWebTest

However it is working in a dotnet core 2.2 console app here https://github.com/tmutton/PdfToImageTest

The settings are the same.

Could anyone shed any light on why this would be?

Thank you

tmutton avatar Jul 12 '19 10:07 tmutton

Your .net core web app is running on Windows (container or not) ? Is pdfium_x64.dll is present in the bin folder ? Using https://github.com/lucasg/Dependencies all the dependencies of pdfium_x64.dll are there ?

Whiletru3 avatar Jul 30 '19 08:07 Whiletru3

Not running in a container and the DLL is in the folder

On Tue, 30 Jul 2019, 09:49 Whiletru3, [email protected] wrote:

Your .net core web app is running on Windows (container or not) ? Is pdfium_x64.dll is present in the bin folder ? Using https://github.com/lucasg/Dependencies all the dependencies of pdfium_x64.dll are there ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ArgusMagnus/PDFiumSharp/issues/11?email_source=notifications&email_token=AA3LNTL5XCQP3NMSJM4I6ADQB76BPA5CNFSM4ICGMYP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3DIS7A#issuecomment-516327804, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3LNTNHA5E4BBUTF27P5ALQB76BPANCNFSM4ICGMYPQ .

tmutton avatar Jul 30 '19 11:07 tmutton

Check what is a working directory and maybe preload the DLL manually. I had similar issues as well

Morcatko avatar Aug 01 '19 12:08 Morcatko

@tmutton Did you manage to load pdfium dll ? I’m facing the same issue. With Nuget package pdfium.dll, it’s working fine, but when I try to load my own pdfium.dll I get the same error as you.

GayashanR avatar Feb 17 '20 06:02 GayashanR

@homeautomationsys It's been a while since I was last in this zone but from memory I wasn't able to achieve this.

tmutton avatar Feb 17 '20 09:02 tmutton

@tmutton , Thank you. Finally I was able to achieve this.

If anyone have the similar issue, try this.

I had to do two fixes. (1). First when we add the dll using “Add Existing item” to the VS project folder, after selecting the dll, choose “Add as Link” button ( not the “Add” ) button. There is a small arrow head in Add button, from there you can choose Add as Link option. (2). After building the pdfium.dll, even though it doesn’t get show errors (Using dependencies checker, use can find missing modules) while it is still in the built folder, when you move the dll to your project folder, you might get errors. (eg: when I move my dll to the project folder, I got I’m missing zlib.dll and libc++.dll, So along with pdfium.dll I added those two dlls to the project as well. Then for each dll, I change properties as Content and Copy if newer.

GayashanR avatar Feb 22 '20 01:02 GayashanR

  1. Refer PDFium dlls using this nuget: PDFium.WindowsV2
    • build solution
    • navigate to bin\Debug\netcoreapp2.2 of startup project
    • pdfium_x64.dll and pdfium_x86.dll should be in there
  2. Change application content root path (working directory) to target bin\Debug\netcoreapp2.2. Here is dotnet issue describing working directory problem and how to adress that - dotnet/project-system/issues/5053

You need to change content root path (working directory) because PDFiumSharp is searching for dlls in the directory where application is run from. By default (in .NET Core 2.2 when run from Visual Studio) content root path is pointing to directory where *.csproj is located but should instead point to dlls output directory (bin\Debug\netcoreapp2.2).

Modestas avatar Oct 13 '20 08:10 Modestas

I am facing the same problem, the DLL is going to the BIN directory, but the application returns: Unable to load DLL 'pdfium_x86': The specified module could not be found. (Exception from HRESULT: 0x8007007E). Can someone help me?

gjrmacedo avatar Oct 19 '21 16:10 gjrmacedo