Hi Team,
We are an existing customer of Dynamic PDF Print Manager.
Our system is currently on version 4.7.0.39844.
When attempting to print with an unavailable printer, the PrintJob.Dispose() method crashes our application. We are receiving a NullReferenceException. We wrote a quick console app that reproduces this. See the code and output below. Attempting to print to an unavailable printer is a valid use case and we handle those exceptions if we could catch them without crashing the app.
OUTPUT:
Exception: The printer named "Kyocera" could not be opened. Error code: 1801.
Unhandled Exception: NullReferenceException
Message: Object reference not set to an instance of an object.
Source: DynamicPDF.Printing.NETFramework40
Stack: at ceTe.DynamicPDF.Printing.PrintJob.Dispose(Boolean disposing)
at ceTe.DynamicPDF.Printing.PrintJob.Finalize()
CODE (It has been through many iterations to try and catch the exception, we've tried a using block with no luck):
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Try to catch it (or at least see it here)
PrintJob pj = new PrintJob("Kyocera"); // This is an unavailable printer name
pj.PrintOptions.DuplexMode = DuplexMode.DuplexVertical;
pj.PrintOptions.Color = true;
pj.PrintOptions.Scaling = PageScaling.ActualSize;
//pj.Failed += Pj_Failed; //Does not get called
pj.DocumentName = $"TEMP PDF.pdf";
Console.WriteLine($"Printing set {pj.DocumentName}...");
var data = LoadPdfData(); // Get some pdf data.
var page = new InputPdf(data);
pj.Pages.Add(page);
pj.Print();
try
{
page.Dispose();
pj.Dispose();
}
catch (NullReferenceException ex)
{
log($"NullReferenceException {ex.Message}."); // We DO NOT this in output
}
log($"Print done {pj.DocumentName}.");
}
catch (Exception ex)
{
log($"Exception {ex.Message}."); // We see this in output
}
//We have this setup as our unhandled exception handler and it is in terminating state when it is thrown from the PrintManager
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception)
{
Logging.LogException(e.ExceptionObject as Exception);
if (e.IsTerminating)
Console.WriteLine("Noooooooo...........");
}
}
Please advise.
PrintManager crashes with bad printername
Re: PrintManager crashes with bad printername
Support · Dec 4, 2019Hello,
Thanks for sharing the complete information. We did testing on our end and able to recreate the error. We will pass this information onto our developers to look into it further. We will post the further updates once the new build of v4 PrintManager which includes fix is available for download.
Thanks,
ceTe Software Support Team
Re: PrintManager crashes with bad printername
Forum member · Dec 18, 2019Thanks. Do you have an ETA on when a fix might be available?
Re: PrintManager crashes with bad printername
Support · Dec 19, 2019Hello,
Our developers are still working on this issue. Please reach out next week for a status update. We should know more at that time.
Thanks,
ceTe Software Support Team
Re: PrintManager crashes with bad printername
Support · Jan 2, 2020Hello,
The issue you reported is fixed. Please contact our support team by sending an email to: [^a|mailto:support@dynamicpdf.com|opennewwindow|support@dynamicpdf.com^] so we can give you link to download the latest DynamicPDF PrintManager product files which includes fix.
Thanks,
ceTe Software Support Team
Re: PrintManager crashes with bad printername
Support · Apr 1, 2020Hello,
This issue was fixed in version 4.10 of DynamicPDF PrintManager. You can download the latest from Nuget (product ID: ceTe.DynamicPDF.Printing.NET) or from our website here
.
Thanks,
ceTe Software Support Team