G
Guest
I am getting a sporadic external exception when drawing a windows metafile.
The odd part about this is that the problem only occurs about one out a
thousand times this code executes, and its the same metafiles that are always
used (so it doesn't appear to be a problem with the metafile itself.) The
code is as follows:
private void PrintLogo(Graphics graphics)
{
//graphics.PageUnit = GraphicsUnit.Display;
ResetTransform( graphics, true );
using(Metafile logo = new Metafile(_printer.LogoImagePath))
{
graphics.DrawImage(logo, 0, 0, LOGO_WIDTH, LOGO_HEIGHT);
}
if(_printer.Report.Type.DrawLogoSeparator)
{
graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 1.0F), 0,
LOGO_HEIGHT, graphics.VisibleClipBounds.Width, LOGO_HEIGHT);
graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 1.0F), 0,
LOGO_HEIGHT + 2, graphics.VisibleClipBounds.Width, LOGO_HEIGHT + 2.0F);
}
}
The exception is as follows:
Event Type: Error
Event Source: Traffic Print Service
Event Category: None
Event ID: 0
Date: 5/23/2005
Time: 4:29:21 PM
User: N/A
Computer: {omitted}
Description:
General Information
*********************************************
Additional Info:
ExceptionManager.MachineName: {omitted}
ExceptionManager.TimeStamp: 5/23/2005 4:29:21 PM
ExceptionManager.FullName: Microsoft.ApplicationBlocks.ExceptionManagement,
Version=1.0.1357.24421, Culture=neutral, PublicKeyToken=null
ExceptionManager.AppDomainName: {omitted}.traffic.output.service.exe
ExceptionManager.ThreadIdentity: {omitted}
ExceptionManager.WindowsIdentity: {omitted}
1) Exception Information
*********************************************
Exception Type: System.Runtime.InteropServices.ExternalException
ErrorCode: -2147467259
Message: A generic error occurred in GDI+.
TargetSite: Void CheckErrorStatus(Int32)
HelpLink: NULL
Source: System.Drawing
StackTrace Information
*********************************************
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Single x, Single y,
Single width, Single height)
at {omitted}.Traffic.Output.TrafficReportPrintDocument.PrintLogo(Graphics
graphics)
at
{omitted}.Traffic.Output.TrafficReportPrintDocument.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 {omitted}.Traffic.Output.ReportPrinter.Print(Boolean preview)
at {omitted}.Traffic.Output.Spooler.Print(PrintRequest request)
at {omitted}.Traffic.Output.Spooler.PrintLoop()
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Thanks in advance for any help you can provide!
Patrick Gannon
The odd part about this is that the problem only occurs about one out a
thousand times this code executes, and its the same metafiles that are always
used (so it doesn't appear to be a problem with the metafile itself.) The
code is as follows:
private void PrintLogo(Graphics graphics)
{
//graphics.PageUnit = GraphicsUnit.Display;
ResetTransform( graphics, true );
using(Metafile logo = new Metafile(_printer.LogoImagePath))
{
graphics.DrawImage(logo, 0, 0, LOGO_WIDTH, LOGO_HEIGHT);
}
if(_printer.Report.Type.DrawLogoSeparator)
{
graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 1.0F), 0,
LOGO_HEIGHT, graphics.VisibleClipBounds.Width, LOGO_HEIGHT);
graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 1.0F), 0,
LOGO_HEIGHT + 2, graphics.VisibleClipBounds.Width, LOGO_HEIGHT + 2.0F);
}
}
The exception is as follows:
Event Type: Error
Event Source: Traffic Print Service
Event Category: None
Event ID: 0
Date: 5/23/2005
Time: 4:29:21 PM
User: N/A
Computer: {omitted}
Description:
General Information
*********************************************
Additional Info:
ExceptionManager.MachineName: {omitted}
ExceptionManager.TimeStamp: 5/23/2005 4:29:21 PM
ExceptionManager.FullName: Microsoft.ApplicationBlocks.ExceptionManagement,
Version=1.0.1357.24421, Culture=neutral, PublicKeyToken=null
ExceptionManager.AppDomainName: {omitted}.traffic.output.service.exe
ExceptionManager.ThreadIdentity: {omitted}
ExceptionManager.WindowsIdentity: {omitted}
1) Exception Information
*********************************************
Exception Type: System.Runtime.InteropServices.ExternalException
ErrorCode: -2147467259
Message: A generic error occurred in GDI+.
TargetSite: Void CheckErrorStatus(Int32)
HelpLink: NULL
Source: System.Drawing
StackTrace Information
*********************************************
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Single x, Single y,
Single width, Single height)
at {omitted}.Traffic.Output.TrafficReportPrintDocument.PrintLogo(Graphics
graphics)
at
{omitted}.Traffic.Output.TrafficReportPrintDocument.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 {omitted}.Traffic.Output.ReportPrinter.Print(Boolean preview)
at {omitted}.Traffic.Output.Spooler.Print(PrintRequest request)
at {omitted}.Traffic.Output.Spooler.PrintLoop()
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Thanks in advance for any help you can provide!
Patrick Gannon