sungaila / PDFtoImage

A .NET library to render PDF files into images.
https://www.sungaila.de/PDFtoImage/
MIT License
188 stars 25 forks source link

System.IO.FileNotFoundException occurs. #97

Closed iriyama-y closed 1 month ago

iriyama-y commented 2 months ago

Question

Help. Built with ASP.NET Core but deployed to IIS on windows server 2022 standard, System.IO.FileNotFoundException: Could not load file or assembly 'PDFtoImage,. Version=4.1.1.0, Culture=neutral, PublicKeyToken=... is raised. The dll was present in the deployment.

It works fine in windows 11 development environment. What is the cause?

sungaila commented 1 month ago

Hi @iriyama-y,

what kind of deployment did you do? Is it a "normal" release build, is it a self-contained publish, publish with AOT, and so on? Are the other dlls like pdfium.dll in the deployment target?

I don't have the setup to test it right now. Running from console and IIS Express works on my machine but I haven't tested it on IIS yet.

iriyama-y commented 1 month ago

Hi sungaila

We place the release builds in a self-contained manner. Target framework is .net 8. We have confirmed that pdfium.dll, PDFtoImage.dll, SkiaSharp.dll, SkiaSharp.Views.Desktop.Common.dll are included. I think it is a problem with the execution environment, but I don't know how to deal with it.

iriyama-y commented 1 month ago

Hi sungaila

I think we can solve this problem. The code that was trying another function similar to PDFtoImage was left behind and the PDFium.dll output from PDFtoImage was overwritten by the PDFium.dll output from the other function. Although the names were the same DLL, the contents were different and caused an inconsistency. We will deploy it again on Windows Server to check and report back.

iriyama-y commented 1 month ago

Hi sungaila

Resolved, it was a DLL conflict. Your library was a good one. I can finish my work successfully. Thank you :-)

sungaila commented 1 month ago

@iriyama-y Glad to hear! :-) Please avoid referencing the pdfium binary files directly and let PDFtoImage select the correct version. In your case, another project has referenced pdfium.

If the pdfium version does not match, you either get a DllNotFoundException or the program will just fail.