GcPdfDocument.Load looking for BouncyCastle.Cryptography.dll

Posted by: bill.emerson on 9 July 2025, 2:45 pm EST

  • Posted 9 July 2025, 2:45 pm EST - Updated 10 July 2025, 7:13 am EST

    We have recently run into a situation that I cannot find an explanation for. We have a new client that is attempting to generate a PDF and on the call to GcPdfDocument.Load the following exception is thrown:

    Unexpected exception occurred while parsing PDF document. Could not load file or assembly ‘BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938’ or one of its dependencies. The system cannot find the file specified.

    The snippet of C# code that is throwing this exception is:

    [code] GcPdfDocument form = new GcPdfDocument();

    try
    {
    	form.Load(ms);
    }
    catch (Exception ex)
    {
    	throw;
    }[/code]
    

    We don’t have any references to BouncyCastle in our API and we do not deploy this DLL with our solution. I have obtained a copy of the PDF being processed and can process it in my development environment so I don’t think there is anything particular to this PDF that requires some type of crypto processing.

    Can anyone help determine why we might be seeing this exception?

    Thank you!

  • Posted 10 July 2025, 9:44 am EST

    Hi Bill,

    Unfortunately, we could not reproduce the issue on our end.

    Just for your information, GcPdfDocument has a dependency on the BouncyCastle.Cryptography package. This is also listed under the Dependencies tab on our NuGet page: https://www.nuget.org/packages/DS.Documents.Pdf#dependencies-body-tab

    To help us investigate further, could you please:

    1. Share the PDF file that triggers the issue? If the PDF contains confidential data, you can submit it via our private support portal by creating a new support case.

    2. Let us know the version of GcPdfDocument you are using, so we can test accordingly.

    3. Provide a screenshot showing all the DLL references in your project, so we can review the dependencies.

    4. Let us know the client environment details, such as the operating system, and whether there are any differences between their setup and yours that might be causing the issue.

    Best Regards,

    Kartik

  • Posted 11 July 2025, 10:05 am EST

    Hi Kartik,

    Thank you for your quick reply. I thought I had attached the PDF that triggered this error to this topic however I don’t see it. I have attempted to re-attach it.

    The version of DS.Documents.Pdf.dll we are running is 7.2.5.0.

    The Mescius related DLLs in our project include:

    DS.Documents.Html.dll

    DS.Documents.Imaging.dll

    DS.Documents.Pdf.dll

    Our solution is a Web based API running under IIS, the OS is Windows Server 2019 (I am running Windows 11 on my workstation). We have this same solution running at a number of other clients with this same configuration, this is the first time we have run into this issue.

    Please let me know if you need any additional information.

    570BA 179-2023.zip

  • Posted 14 July 2025, 1:02 pm EST - Updated 14 July 2025, 1:08 pm EST

    Hi Bill,

    Thank you for the details and for sharing the PDF file.

    We’ve tested the provided document in a similar environment using DS.Documents.Pdf.dll version 7.2.5, and the PDF loads successfully, both with and without the BouncyCastle.Cryptography DLL present in the project. Based on this, it appears that the presence of the BouncyCastle assembly may not be the root cause of the exception.

    To help us investigate further, we would need a minimal reproducible project or a sample deployment that triggers the exception on your client’s machine with the illustrative video recording. This will allow us to identify any environment-specific or deployment-specific issues on IIS.

    You can further refer to the attached sample application used to investigate the issue on our end, with the working screenshot and the system configurations.

    Attachment: DsPdfWebApi.zip

    Working:

    System Configurations:

    Best Regards,

    Chirag Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels