• When I'm using it in a multi-threaded environment, with multiple PDF's being generated at once, each thread with its own instance of the .NET wrapper class, I'm getting occasional exceptions which I'm having trouble finding any reason for. The exception is:

    Code
    Object reference not set to an instance of an object.
       at wPDF.wPDFControlDLL.EndPage(Int32 env)
       at wPDF.wPDFControlWrap.EndPage(Int32 env)
       at wPDF.PDFControl.EndPage()
       at Mynamespace.Printing.PdfPrintController.OnEndPage(PrintDocument document, PrintPageEventArgs e)
       at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
       at System.Drawing.Printing.PrintController.Print(PrintDocument document)
       at System.Drawing.Printing.PrintDocument.Print()
       at Mynamespace.PrintIdentifiersPDF.Print()

    Any ideas what would cause this? I've never had this happen in a single threaded use. Thanks.

  • ... and in my last multi-threaded test run, the following exception:

    Code
    Object reference not set to an instance of an object.
       at wPDF.wPDFControlDLL.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
       at wPDF.wPDFControlWrap.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
       at wPDF.PDFControl.CloseCanvas()
       at wPDF.PDFControl.EndPage()
       at MyNamespace.PdfPrintController.OnEndPage(PrintDocument document, PrintPageEventArgs e) in D:\mysource\PdfPrintController.cs:line 48
       at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
       at System.Drawing.Printing.PrintController.Print(PrintDocument document)
       at System.Drawing.Printing.PrintDocument.Print()
       at MyNamespace.PrintIdentifiersPDF.Print() in d:\mysource\printidentifierspdf.cs:line 117
  • Same here sometimes, I get the exception that the page couldn't be started because there wasn't a begindoc call. but the call was there, and somethimes it just works fine.

    It would be nice if there would be a bugfix for this soon.

  • Hi Julian

    I've taken a look into the c# source code of the wrapper class. The problem I found out, are the calls from the wPDFControlWrap calls to the static wPDFControlDLL class. Only one thread could actually call a function on the static wPDFControlDLL, that goes to the wpdfControl02.dll. I synchronized the calls and now everything works just fine. Tried 1000 loops with 4-10 threads without any problem.

    If you would like I can send you the modified code of the wPDFControlWrap and wPDFControlDLL class by mail?

    Kind Regards
    Fabrizio

  • Has the new syncronization code been added to wPDF file version 2.7 (NET20)? I am running into similar issues while multiple threads are creating PDFs at the same time. Runs for a while and then all threads get exceptions such as:

    Thread1 gets:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    while in

    System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at wPDF.wPDFControlDLL.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
    at wPDF.wPDFControlWrap.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
    at wPDF.PDFControl.CloseCanvas()
    at wPDF.PDFControl.EndPage()

    and on the other thread I get:

    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at wPDF.wPDFControlDLL.StartPage(Int32 env, Int32 Width, Int32 Height, Int32 Rotation)
    at wPDF.wPDFControlWrap.StartPage(Int32 env, Int32 Width, Int32 Height, Int32 Rotation)
    at wPDF.PDFControl.StartPage(Int32 w, Int32 h, Boolean landscape)
    at wPDF.PDFControl.StartPage(ePage format, Boolean landscape)
    at wPDF.PDFControl.StartPage()

    Thank you for any help on this!! :)