PDFiumSharp
PDFiumSharp copied to clipboard
Unable to load DLL 'pdfium_x64'
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
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 ?
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 .
Check what is a working directory and maybe preload the DLL manually. I had similar issues as well
@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.
@homeautomationsys It's been a while since I was last in this zone but from memory I wasn't able to achieve this.
@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.
- Refer PDFium dlls using this nuget: PDFium.WindowsV2
- build solution
- navigate to
bin\Debug\netcoreapp2.2
of startup project -
pdfium_x64.dll
andpdfium_x86.dll
should be in there
- 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
).
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?