Search code examples
c#multithreadingconcurrencynreco

System.Exception: Invalid license key at NReco.PdfRenderer.License while using the PdfToImageConverter.GenerateImage concurrently


I'm trying to use the PdfToImageConverter.GenerateImage method concurrently, in various threads:

new PdfToImageConverter
{
    ScaleTo = this.settings.ScaleTo
}
.GenerateImage(
    pdfContentStream,
    task.Page,
    ImageFormat.Png,
    outputContentStream);

Usually, the method works fine, but sometimes it throws an exception:

System.Exception: Invalid license key
at NReco.PdfRenderer.License.a.B()
at NReco.PdfRenderer.PdfToImageConverter.b(A )
at NReco.PdfRenderer.PdfToImageConverter.A(A )

I set the license info once at the start of our service:

NReco.PdfRenderer.License.SetLicenseKey(
    "PDF_Renderer_Bin_Pack_....",            
    "Pc...30=");

Is the PdfToImageConverter.GenerateImage thread-safe, and how can I use the method in a multithreaded environment?

Thanks!


Solution

  • The problem has been resolved in the latest version. We used outdated product version.