fo-dicom-samples icon indicating copy to clipboard operation
fo-dicom-samples copied to clipboard

Print SCP intermittent error

Open iamps opened this issue 7 years ago • 15 comments

Print scp intermittently throws following error even if same job is sent to it which was just printed:

Print Job 5581685231640871 Status Failure: Printing failed, exception: System.ArgumentException: Parameter is not valid.    at System.Drawing.Image.get_Height()    at Dicom.Printing.ImageBoxExtensions.DrawBitmap(Graphics graphics, RectF box, Image bitmap, Int32 imageResolution, String emptyImageDensity) in C:\fo-dicom\DICOM\Printing\ImageBoxExtensions.cs:line 129    at Dicom.Printing.ImageBoxExtensions.Print(ImageBox imageBox, Graphics graphics, RectF box, Int32 imageResolution) in C:\fo-dicom\DICOM\Printing\ImageBoxExtensions.cs:line 55    at Dicom.Printing.FilmBoxExtensions.Print(FilmBox filmBox, Graphics graphics, Rectangle marginBounds, Int32 imageResolution) in C:\fo-dicom\DICOM\Printing\FilmBoxExtensions.cs:line 92    at Dicom.Printing.PrintJob.OnPrintPage(Object sender, PrintPageEventArgs e) in F:\fo-dicom 06Sept2017\fo-dicom-samples-master\Desktop\Print SCP\PrintJob.cs:line 350    at System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e)    at System.Drawing.Printing.PrintDocument._OnPrintPage(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 Dicom.Printing.PrintJob.DoPrint() in F:\fo-dicom 06Sept2017\fo-dicom-samples-master\Desktop\Print SCP\PrintJob.cs:line 325

What could be the reason.

iamps avatar Sep 08 '17 06:09 iamps

Thanks for reporting, @iamps. I have occasionally seen a similar error, and I suspect that it has something to do either with ownership or disposal of the rendered Bitmap. Which version of the fo-dicom NuGet package are you using?

anders9ustafsson avatar Sep 08 '17 12:09 anders9ustafsson

NuGet version is showing 2.8.50926.602

Sent from Outlookhttp://aka.ms/weboutlook


From: Anders Gustafsson [email protected] Sent: Friday, September 8, 2017 5:55 PM To: fo-dicom/fo-dicom-samples Cc: iamps; Mention Subject: Re: [fo-dicom/fo-dicom-samples] Print SCP intermittent error (#12)

Thanks for reporting, @iampshttps://github.com/iamps. I have occasionally seen a similar error, and I suspect that it has something to do either with ownership or disposal of the rendered Bitmap. Which version of the fo-dicom NuGet package are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fo-dicom/fo-dicom-samples/issues/12#issuecomment-328089301, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcmqTPF2OOLVve_exJIrTQyIGiMG1D3Jks5sgTIegaJpZM4PQxRd.

iamps avatar Sep 08 '17 12:09 iamps

Sorry for being unclear. I meant which fo-dicom version are you using?

anders9ustafsson avatar Sep 08 '17 12:09 anders9ustafsson

3.0.0.4

Sent from Outlookhttp://aka.ms/weboutlook


From: Anders Gustafsson [email protected] Sent: Friday, September 8, 2017 6:23 PM To: fo-dicom/fo-dicom-samples Cc: iamps; Mention Subject: Re: [fo-dicom/fo-dicom-samples] Print SCP intermittent error (#12)

Sorry for being unclear. I meant which fo-dicom version are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fo-dicom/fo-dicom-samples/issues/12#issuecomment-328095276, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcmqTJ4R0K9CioH7xghN5v8KkEgE0RtWks5sgTjlgaJpZM4PQxRd.

iamps avatar Sep 08 '17 13:09 iamps

If I use fo-dicom ver 3.1.0.1, Print SCP project gives lot of errors.

Is there a Print scp compatible with fo-dicom ver 3.1.0.1

Sent from Outlookhttp://aka.ms/weboutlook


From: Anders Gustafsson [email protected] Sent: Friday, September 8, 2017 6:23 PM To: fo-dicom/fo-dicom-samples Cc: iamps; Mention Subject: Re: [fo-dicom/fo-dicom-samples] Print SCP intermittent error (#12)

Sorry for being unclear. I meant which fo-dicom version are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fo-dicom/fo-dicom-samples/issues/12#issuecomment-328095276, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcmqTJ4R0K9CioH7xghN5v8KkEgE0RtWks5sgTjlgaJpZM4PQxRd.

iamps avatar Sep 08 '17 14:09 iamps

The samples have not been updated to use 3.1.0-alpha. It would help though if you could publish the errors you are getting with that version. Is it compilation errors or runtime errors?

anders9ustafsson avatar Sep 08 '17 14:09 anders9ustafsson

compilation errors

Sent from Outlookhttp://aka.ms/weboutlook


From: Anders Gustafsson [email protected] Sent: Friday, September 8, 2017 7:37 PM To: fo-dicom/fo-dicom-samples Cc: iamps; Mention Subject: Re: [fo-dicom/fo-dicom-samples] Print SCP intermittent error (#12)

The samples have not been updated to use 3.1.0-alpha. It would help though if you could publish the errors you are getting with that version. Is it compilation errors or runtime errors?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fo-dicom/fo-dicom-samples/issues/12#issuecomment-328112843, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcmqTIaKKgIg7OwSAPrziHTpsSfuRLMXks5sgUozgaJpZM4PQxRd.

iamps avatar Sep 08 '17 14:09 iamps

The only error now is in PrintService.cs

public class PrintService : DicomService, IDicomServiceProvider, IDicomNServiceProvider, IDicomCEchoProvider {

}

Severity Code Description Project File Line Suppression State Error CS0738 'PrintService' does not implement interface member 'IDicomServiceProvider.OnReceiveAssociationReleaseRequestAsync()'. 'PrintService.OnReceiveAssociationReleaseRequestAsync()' cannot implement 'IDicomServiceProvider.OnReceiveAssociationReleaseRequestAsync()' because it does not have the matching return type of 'Task'.

Sent from Outlookhttp://aka.ms/weboutlook


From: Anders Gustafsson [email protected] Sent: Friday, September 8, 2017 7:37 PM To: fo-dicom/fo-dicom-samples Cc: iamps; Mention Subject: Re: [fo-dicom/fo-dicom-samples] Print SCP intermittent error (#12)

The samples have not been updated to use 3.1.0-alpha. It would help though if you could publish the errors you are getting with that version. Is it compilation errors or runtime errors?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fo-dicom/fo-dicom-samples/issues/12#issuecomment-328112843, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcmqTIaKKgIg7OwSAPrziHTpsSfuRLMXks5sgUozgaJpZM4PQxRd.

iamps avatar Sep 08 '17 15:09 iamps

Please suggest correction.

iamps avatar Sep 09 '17 01:09 iamps

I think I was using wrong Dicomcore.dll. Used ver 3.0.0.4 , also the original issue of bitmap resolved.

Thanks

iamps avatar Sep 09 '17 02:09 iamps

So is this issue now still open, or can it be closed?

gofal avatar Jan 19 '18 09:01 gofal

In fact, I'm victim of theses errors, and I can't find a way to solve them. My version is 3.0.2. I'm using the same Bitmap object (created from RenderImage().AsBitmap()) to save the image in multiple resolutions, and I've noticed the error never occurs on the first .Save() call. I'm not calling .Dispose() on anything before having finished. Maybe the issue is related? Do you think calling RenderImage().AsBitmap() for every save is necessary?

tartinesKiller avatar Mar 13 '18 16:03 tartinesKiller

This relates to the issue in fo-dicom https://github.com/fo-dicom/fo-dicom/issues/634 There is already a pull request solving this issue. Of course you did not dispose the Bitmap. But the RenderImage().AsBitmap() returns a Bitmap that does NOT own its own memory but instead points to the memory owned by the IImage object (the one with the method RenderImage()). If then the garbage collector dispose this IImage object, then the memory containing the pixel data is erased and the Bitmaps pointer gets invalid. Until the fix is published in next release, you could just keep the IImage instance in memory, eg as a member variable in the same scope as the Bitmap. Or you always create the Bitmap with RenderImage().AsBitmap().Clone() which immediatelly copies the whole pixel data into a new memory that is then owend by the Bitmap.

gofal avatar Mar 13 '18 20:03 gofal

Thanks for the great explanation! I didn't find the existing issue, sorry.

tartinesKiller avatar Mar 13 '18 21:03 tartinesKiller

Is it resolved? I still get the error using AsClonedBitmap

GeovaneW96 avatar Feb 11 '19 09:02 GeovaneW96