A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


04-10-2008, 8:35 AM
I have just started using Active Reports 3 (build 5.2.3.685) and have got the report working fine. However on one of the larger data sets, the report stops in a particular place and throws a fist chance exception 'System.ArgumentException' occurred in System.Drawing.dll. This occurs as the details_format finshes. The stack trace is

System.ArgumentException was unhandled by user code
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.Image.get_RawFormat()
at DataDynamics.ActiveReports.Document.-10b2.-f100(-10b2 resourceIn)
at DataDynamics.ActiveReports.Document.-3332.-d012(Object resource, Boolean resourceChanged)
at DataDynamics.ActiveReports.Document.Page.-2cfa(Object data, Boolean resourceChanged, Int32& id)
at DataDynamics.ActiveReports.Document.Page.DrawImage(Image image, Single left, Single top, Single width, Single height)
at DataDynamics.ActiveReports.ChartControl.-2a3(GraphicsCache cache, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.ARControl.-a21(GraphicsCache gRef, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.Section.-ddee(GraphicsCache cache, Page page, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)
at DataDynamics.ActiveReports.Section.-11ba(GraphicsCache cache, -cbba rData)
at DataDynamics.ActiveReports.-db32.-d2ae()
at DataDynamics.ActiveReports.-db32.-efca(Section section, Int32 insPos)
at DataDynamics.ActiveReports.-db32.-a22e(Section section)
at DataDynamics.ActiveReports.-0ea2.-cd0b()
at DataDynamics.ActiveReports.-0ea2.-e1de(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status)
at DataDynamics.ActiveReports.ActiveReport3.-f1d()
at DataDynamics.ActiveReports.ActiveReport3.Run(Boolean syncDocument)
at _Default.form1_Init(Object sender, EventArgs e) in C:\Documents and Settings\cemrjc\My Documents\Visual Studio 2005\WebSites\BasicFeedback\Default.aspx.vb:line 15
at System.Web.UI.Control.OnInit(EventArgs e)
at System.Web.UI.HtmlControls.HtmlForm.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The report is bound to an SQL Server stored proc and is being generated in VS2005. If I prune the recordset (leaving the data from where the report stopped to the end), then the report finishes OK, so it cannot be the data at fault. I tried running the report using CachetoDisk, but ths did not solve the problem (the report stopped when the cached disk file was about 70 Mb, so it was not overly large). As the details section fills, I run another query to retrieve extra data used to generate series on the inbuilt charting tool.

The report (by the time it stopped) would have hd around 1000 pages and 4,000 (or so) different charts.

Has this come up before and does anyone have any ideas what is causing this ?

Regards

Robert

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


04-10-2008, 12:42 PM

Hello ,

I recommend you to update the Active Reports .NET 3.0 to the latest build.

It is available here:

http://www.datadynamics.com/forums/72/ShowForum.aspx

Also, i would like to know the following details:

1) Does problem appear in windows forms application?

2) Is KeepTogether property of detail section set to "True"?

3) Did you try to set the ImageType property of chart control to "PNG" value?

Thanks,

Sergey Romanov.

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


04-11-2008, 6:07 AM
Sergey

Thans for the response. The problem originally occured when being called from a Web page. I have movd the report into a windows application projct and called it from a windows form. The report still does not complete at approx the same place, and I got the following stack dump

A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionTestAR.vshost.exeSystem.Runtime.InteropServices.ExternalException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089A generic error occurred in GDI+. at System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, EmfType type, String description)
at System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, EmfType type)
at DataDynamics.ActiveReports.Document.CanvasItem.-bc2(Image image)
at DataDynamics.ActiveReports.Document.-10b2.-f100(-10b2 resourceIn)
at DataDynamics.ActiveReports.Document.-3332.-d012(Object resource, Boolean resourceChanged)
at DataDynamics.ActiveReports.Document.Page.-2cfa(Object data, Boolean resourceChanged, Int32& id)
at DataDynamics.ActiveReports.Document.Page.DrawImage(Image image, Single left, Single top, Single width, Single height)
at DataDynamics.ActiveReports.ChartControl.-2a3(GraphicsCache cache, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.ARControl.-a21(GraphicsCache gRef, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.Section.-ddee(GraphicsCache cache, Page page, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)
at DataDynamics.ActiveReports.Section.-11ba(GraphicsCache cache, -cbba rData)
at DataDynamics.ActiveReports.-db32.-d2ae()
at DataDynamics.ActiveReports.-db32.-efca(Section section, Int32 insPos)
at DataDynamics.ActiveReports.-0ea2.-cd0b()
at DataDynamics.ActiveReports.-0ea2.-e1de(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status)
at DataDynamics.ActiveReports.ActiveReport3.-f1d()
at DataDynamics.ActiveReports.ActiveReport3.Run(Boolean syncDocument)
at TestAR.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\cemrjc\My Documents\Visual Studio 2005\Projects\TestAR\TestAR\Form1.vb:line 13
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at TestAR.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, EmfType type, String description)
at System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, EmfType type)
at DataDynamics.ActiveReports.Document.CanvasItem.-bc2(Image image)
at DataDynamics.ActiveReports.Document.-10b2.-f100(-10b2 resourceIn)
at DataDynamics.ActiveReports.Document.-3332.-d012(Object resource, Boolean resourceChanged)
at DataDynamics.ActiveReports.Document.Page.-2cfa(Object data, Boolean resourceChanged, Int32& id)
at DataDynamics.ActiveReports.Document.Page.DrawImage(Image image, Single left, Single top, Single width, Single height)
at DataDynamics.ActiveReports.ChartControl.-2a3(GraphicsCache cache, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.ARControl.-a21(GraphicsCache gRef, Page page, PointF pageOffset, Single startPos, Single endPos)
at DataDynamics.ActiveReports.Section.-ddee(GraphicsCache cache, Page page, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)
at DataDynamics.ActiveReports.Section.-11ba(GraphicsCache cache, -cbba rData)
at DataDynamics.ActiveReports.-db32.-d2ae()
at DataDynamics.ActiveReports.-db32.-efca(Section section, Int32 insPos)
at DataDynamics.ActiveReports.-0ea2.-cd0b()
at DataDynamics.ActiveReports.-0ea2.-e1de(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status)
at DataDynamics.ActiveReports.ActiveReport3.-f1d()
at DataDynamics.ActiveReports.ActiveReport3.Run(Boolean syncDocument)
at TestAR.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\cemrjc\My Documents\Visual Studio 2005\Projects\TestAR\TestAR\Form1.vb:line 13
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at TestAR.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

In reply to your other questions

Keep together iss set to true
Image Type property of the chart is set to metafile

Regards

Robert

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


04-15-2008, 7:27 AM

Hello ,

What results do you get when the ImageType property of chart control is set to "PNG" value?

Did you install the latest build of Active Reports .NET 3.0  ?

Thanks,

Sergey Romanov.

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


07-01-2008, 10:34 AM
Sergey

I appreciate that it has been a while - however I have been distractd by many other tsaks.

I upgraded to the latest version - no joy. I ran the report with the ImageType property set to png and that did run through OK. HOWEVER..... the image quality, even when set to high, was not really acceptable (certainly not print ready) when compared to the metafile version. In addtiton I am exporting the reports to pdf and when I run them using png images the pdf file increses enourmously - i.e. a pdf file that is about 1.5 Mb when using metafile images grows to in excess of 20Mb when using the png images - this is unusable. Any further thoughts ? At the moment all I can contemplate doing is splitting the report into two sections, which I would rather not have to do. The same report written for ActiveReports 2 (ActiveX using VB6) does not appear to have ths problem. Thus this problem is preventing my migration to .Net.

Thanks in advance for your continuing help,

Regards

Robert

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


07-02-2008, 10:20 AM

Hello ,

Could you please send me VB. and .RESX files with report?

Thanks,

Sergey Romanov.

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


07-18-2008, 4:42 AM
THe main report is PredictStudents. This contains a subreport called IndStudent. Files attached in Zip file.

Robert

Re: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll


07-21-2008, 6:12 AM

Hello ,

The reports you sent do not throw the GDI and argument exceptions on my machine.

The project with test is attached.

Try to comment out the code with markes and annotations for check.

Thanks,

Sergey Romanov.