AccessViolationException in Graphics3DGdiPlus class.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
WD_Gordon
Newbie
Newbie
Posts: 49
Joined: Wed Jun 18, 2008 12:00 am

AccessViolationException in Graphics3DGdiPlus class.

Post by WD_Gordon » Tue Nov 11, 2008 8:13 pm

Hi,

I randomly get an AccessViolationException in the Graphics3DGdiPlus class in the method ClipRectangle when SetClipRegion(new Region(CorrectRectangle(r))) is called.

Here is the exception:
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System.Drawing"
StackTrace:
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateRegionRectI(GPRECT& gprect, IntPtr& region)
at System.Drawing.Region..ctor(Rectangle rect)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.ClipRectangle(Rectangle r) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Drawing\CanvasGDIplus.cs:line 818
at Steema.TeeChart.Drawing.Graphics3D.ClipRectangle(Int32 left, Int32 top, Int32 right, Int32 bottom) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Drawing\Canvas.cs:line 7289
at Steema.TeeChart.Drawing.Graphics3D.ClipCube(Rectangle rect, Int32 minZ, Int32 maxZ) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Drawing\Canvas.cs:line 7501
at Steema.TeeChart.Styles.Series.ClipRegionCreate(Boolean& ActiveRegion) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Series.cs:line 3129
at Steema.TeeChart.Styles.Series.DrawSeries() in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Series.cs:line 3307
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Chart.cs:line 942
at Steema.TeeChart.Chart.InternalDraw(Graphics g) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\Chart.cs:line 807
at Steema.TeeChart.TChart.Draw(Graphics g) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\TeeChart.cs:line 566
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe) in C:\Projects\Projects\ITRADEFX\TeeChart for .NET v3 Full Source Code\Sources\TeeChart\TeeChart.cs:line 606
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.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(Form mainForm)
at ITradeFx.Windows.Program.Main() in C:\Projects\Projects\ITRADEFX\ITradeFx Chart Control\ControlsTestApp\ControlsTestApp\Program.cs:line 17
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()
Would you have any idea why this is happening? I am running a C# app on XP.

Thanks,
Kevin

WD_Gordon
Newbie
Newbie
Posts: 49
Joined: Wed Jun 18, 2008 12:00 am

Post by WD_Gordon » Wed Nov 12, 2008 12:34 am

Just to add to this. I made some changes and I am still getting AccessViolationException errors but in another area. I am creating an empty candle chart, meaning no data. I pass in data, adding a candle and in the BeforeDrawSeries event I have code as follows:

Code: Select all

pen.DashStyle = DashStyle.Custom;
pen.DashPattern = new float[] { 2.0F, 6.0F, 4.0F };

path.AddLine(this.tChart1.Axes.Bottom.CalcPosValue(this.tChart1.Axes.Bottom.Minimum),
	this.tChart1.Axes.Right.CalcPosValue(this.currentPrice),
        this.tChart1.Axes.Bottom.CalcPosValue(this.tChart1.Axes.Bottom.Maximum),
        this.tChart1.Axes.Right.CalcPosValue(this.currentPrice));

g.DrawPath(pen, path);
When DrawPath is called that is when I get AccessViolationExceptions. I tried adding this code to the AfterDraw event but I still get it. It seems to be a timing issue because it doesn't happen everytime.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 12, 2008 9:13 am

Hi Kevin,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here and let us know the TeeChart version you are using?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply