Warm tip: This article is reproduced from serverfault.com, please click

Spire PDF SaveToFile Crashes Program

发布于 2020-11-22 08:49:46

I'm trying to save a PDF file to folder, I'm using Spire.PDF for that.

I'm creating the PdfCodument from a byte[] and when I try to save it to file I get an error message and the program falls.

PdfDocument pdf = new PdfDocument(baseReport);
.
.
.
pdf.SaveToFile("E:\\Temp 2\\" + Guid.NewGuid().ToString() + ".pdf");

The error message says:

Could not load file or assembly 'Spire.License, Version=1.3.8.40, Culture=natural...' or one of its dependencies. The system cannot find the file specified.

The thing is that I have reference to the Spire.License dll and it is from version 1.3.8.40.

What am I doing wrong?

Thank you in advance!

Questioner
itzick binder
Viewed
0
vaalex 2020-11-30 10:28:50

I have two suggestions for you -

Option 1.Check if the ‘Target Framework’ of your project is properly set. For example, if you refereneced Spire.Pdf.dll and Spire.License.dll from the '.NET 4.0' folder, you'll need to set the 'Target Framework' to '.NET Framwork 4'. Meanwhile, make sure the Spire.Pdf.dll and Spire.License.dll are from the same folder.

Option 2. If the option 1 does not work, remove all DLLs from your project, and re-install the DLL files via NuGet. This method should solve your issue.

https://www.nuget.org/packages/Spire.PDF/