An exception occurs when using Aspose.PDF for .NET from GAC under .NET 4.0

Hi Team,

We recently updated the Aspose.PDF.dll version 23.6.
After updating we are getting below error while adding a Image to the PDF.

I could find the same error reported in below thread long back but couldn’t find any solutions. Is there a fix/any workaround for this?

https://forum.aspose.com/t/could-not-load-file-or-assenbly-aspose-imaging-version-22-5-0-0/247892

Code snippet:
Pdf.Document pdfDoc = new Pdf.Document();
using (MemoryStream byteStream = new MemoryStream(documentData))
{
pdfDoc.Pages.Add();
Pdf.Page page = pdfDoc.Pages[1];
page.AddImage(byteStream, page.GetPageRect(false));
}
return pdfDoc;

Error Message:
Invalid image stream (Could not load file or assembly ‘Aspose.Imaging, Version=23.5.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.)
Exception Type: System.ArgumentException
HResult: -2147024809
Source: Aspose.PDF
TargetSite: Void #=zXQkmo1II5XgQ0jUe4g==(System.IO.Stream, #=z7azlXfd9OpQr4VVGb9m8NmF3mZO7w$O40A1Q8bI5L5vb, #=zlZ6ALFULL_R9eHH9k$jWkxNungh9dSi1kQ==, Int32, System.Drawing.Image ByRef, System.IO.Stream)
StackTrace: at Aspose.Pdf.XImageCollection.#=zXQkmo1II5XgQ0jUe4g==(Stream #=zmpvdKoU=, #=z7azlXfd9OpQr4VVGb9m8NmF3mZO7w$O40A1Q8bI5L5vb #=zKfBOf64=, #=zlZ6ALFULL_R9eHH9k$jWkxNungh9dSi1kQ== #=z6pggJ6g=, Int32 #=zsEszqF4=, Image& #=z_By7zjaqCkw5, Stream #=zWR41AD1JbkLhocm$a39ZwyM=)
at Aspose.Pdf.XImageCollection.#=zydts02x$JdnV(Int32 #=z9vEF16M=, Stream #=zmpvdKoU=, Int32 #=zsEszqF4=, Boolean #=zLCBPEfrSgOmK, ImageFilterType #=zmDdsHME=, Byte #=z9FHAFJq6$PAY, Boolean #=zMmM23$I=, String& #=z8RLGq7Dy_rCF, Stream #=zWR41AD1JbkLhocm$a39ZwyM=, Boolean #=zbbDYaV7IQDsL, Boolean #=zGJd3z5yaTKDMCPuSqg==)
at Aspose.Pdf.XImageCollection.#=zydts02x$JdnV(Int32 #=z9vEF16M=, Stream #=zmpvdKoU=, Int32 #=zsEszqF4=, Boolean #=zLCBPEfrSgOmK, ImageFilterType #=zmDdsHME=, Boolean #=zMmM23$I=, Stream #=zWR41AD1JbkLhocm$a39ZwyM=)
at Aspose.Pdf.XImageCollection.#=zqjEKHF8=(Stream #=zmpvdKoU=, Int32 #=zsEszqF4=, Boolean #=zLCBPEfrSgOmK, ImageFilterType #=zmDdsHME=, Boolean #=zMmM23$I=, Stream #=zWR41AD1JbkLhocm$a39ZwyM=)
at Aspose.Pdf.Page.#=zK6vdKsI=(Stream #=zmpvdKoU=, Rectangle #=zKx8r14U=, Matrix #=z4w0OXZ66Cio7, CompositingParameters #=z8ClHcqAd42oaZV9lA102QC0=, Boolean #=z4U88DFg=, Boolean #=zLCBPEfrSgOmK, #=zlZ6ALFULL_R9eHH9k$jWk_qQmuhrxEotgQ==& #=zaGimHjXiNp1L, Stream #=zWR41AD1JbkLhocm$a39ZwyM=, Boolean #=zY$MXQN8=, Int32 #=zDTlckp9JCtRO)
at Aspose.Pdf.Page.#=zK6vdKsI=(Stream #=zmpvdKoU=, Rectangle #=zKx8r14U=, Matrix #=z4w0OXZ66Cio7, CompositingParameters #=z8ClHcqAd42oaZV9lA102QC0=, #=zlZ6ALFULL_R9eHH9k$jWk_qQmuhrxEotgQ==& #=zaGimHjXiNp1L, Boolean #=zY$MXQN8=, Int32 #=zDTlckp9JCtRO)
at Aspose.Pdf.Page.#=zK6vdKsI=(Stream #=zmpvdKoU=, Rectangle #=zKx8r14U=, CompositingParameters #=z8ClHcqAd42oaZV9lA102QC0=)
at Aspose.Pdf.Page.AddImage(Stream imageStream, Rectangle imageRect)

Thank You!

@hariprasanth1998

Would you please try using 23.10 version of the API and if issue still persists, please share your sample document with us. We will test the scenario in our environment and address it accordingly.

Hi @asad.ali,

I am facing the same issue when using 23.10 as well. It is working fine in Aspose.PDF.dll 12.0 version.

Also I am unable to upload the sample application (Zip File) here. Is there any other way to share the files.

Thank You!

Hi @asad.ali,

I am still facing issue uploading the sample application.

Could you please just host a simple web application with below code to convert any image to PDF?

byte[] bytes1 = System.IO.File.ReadAllBytes(“”);
Pdf.Document pdfDoc = new Pdf.Document();
using (MemoryStream byteStream = new MemoryStream(bytes1))
{
pdfDoc.Pages.Add();
Pdf.Page page = pdfDoc.Pages[1];
page.AddImage(byteStream, page.GetPageRect(false));
}
pdfDoc.Save(“”);

It is replicating only in a web application hosted in IIS. Its working fine in a console application.

Thank You!

@hariprasanth1998

Would it be possible for you to share your sample application in .zip format? You can simply remove the DLLs from the *bin folder(s) and reduce the package size to allow uploading here with your post. We will perform initial investigation in our environment and address the issue accordingly.

Hi @asad.ali,

We have a restriction at organizational level for uploading files.
Could you please try creating a simple web application with below code and replicate it?

byte[] bytes1 = System.IO.File.ReadAllBytes(“PATH_TO_ANY_IMAGE_FILE”);
Pdf.Document pdfDoc = new Pdf.Document();
using (MemoryStream byteStream = new MemoryStream(bytes1))
{
pdfDoc.Pages.Add();
Pdf.Page page = pdfDoc.Pages[1];
page.AddImage(byteStream, page.GetPageRect(false));
}
pdfDoc.Save(“PATH_TO_SAVE_PDF”);

Note: It is replicating only in a web application hosted in IIS. Its working fine in a console application.

Thank You!

@hariprasanth1998

Can you please share the specifications of web application? Could it be any e.g. MVC, ASP.NET Web Forms? Are you using .NET Core?

Hi @asad.ali,

I replicated using ASP.NET Web Forms. Not using .Net Core.

Thank You!

@hariprasanth1998

We tested using 23.11 version of the API in ASP.NET WebForms application and were unable to notice any issues.
image.png (49.5 KB)

We request you please share some more details which can help us in replicating the issue in our environment.

Hi @asad.ali

Could you please try registering the Aspose.Pdf.dll in GAC and point it in GAC?

.Net Version: 4.0

@hariprasanth1998

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55981

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @asad.ali

Could you please provide an ETA on the fix?

@hariprasanth1998

The ticket has just been logged in our issue management system and it will be investigated on a first come first serve basis as per free support policies. As soon as it is investigated, we will be able to share some ETA or updates with you. Please be patient and spare us some time. We are sorry for the inconvenience.

Hi @asad.ali,

Any update on this?

@hariprasanth1998

We are afraid that the ticket has not been yet resolved. However, we will surely inform you as soon as we make some updates about ticket resolution. Please spare us some time.

Hi @asad.ali,

Any update on this? Any ETA?

Thank You!

@hariprasanth1998

We are afraid that the earlier logged ticket has not been fully analyzed and investigated yet. As shared earlier, we will surely prioritize it on a first come first serve basis and as soon as we make some updates, we will update you. Please spare us some time. We apologize for the inconvenience.

Hi @asad.ali,

Any update on this? Could you please provide an ETA?

Thank You!

@hariprasanth1998

We are afraid that any promising ETA cannot be shared at the moment because the investigation is not yet completed. As soon as we are in a position to share some updates in this regard, we will let you know. We apologize for the inconvenience.

Hi @asad.ali,

Any update on this?

Thank You!