Attempted to write to protected memory when saving chart.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
QSI
Newbie
Newbie
Posts: 4
Joined: Fri Mar 17, 2006 12:00 am

Attempted to write to protected memory when saving chart.

Post by QSI » Fri Jun 22, 2007 4:26 pm

We have a web based application developed in VB.NET that uses TeeChart to produce graphs as jpeg images which we then display on a web page. Code similiar to this:

Code: Select all

Private ChartProcessor As Steema.TeeChart.TChart

Private Sub GetChart(thisStartDate As String, thisDataTable As Object)

    '-----------------------------------------
    '  This routine creates the chart
    '------------------------------------------
    Call TChart_Create(thisStartDate, thisDataTable)             

    '--------------------------------------------------------
    '  Jpeg is written to a session object for retrieval  
    '---------------------------------------------------------
      
    thisStream = New System.IO.MemoryStream()
    ChartProcessor.Export.Image.JPEG.Save(thisStream)
                    
    Sess.Contents("Chart" & thisChartID) = thisStream

End Sub

The function wil run fine for awhile but eventually we get the following error:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipGetImageGraphicsContext(HandleRef image, IntPtr& graphics)

at System.Drawing.Graphics.FromImage(Image image)

at Steema.TeeChart.Chart.Bitmap(Int32 width, Int32 height, PixelFormat pixelformat)

at Steema.TeeChart.Chart.Bitmap(Int32 width, Int32 height)

at Steema.TeeChart.Export.ImageExportFormat.Save(Stream stream)
After this error is received, the function errors every time after that untill we reset IIS on the webserver.

TeeChart 2.0.2179.21171
NET 2.0
Windows Server 2003

Any ideas?

Thanks for looking.

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

Post by Narcís » Mon Jun 25, 2007 7:42 am

Hi QSI,

Please notice that the version you are using is quite old and a number of new maintenance releases have been posted since your version was out. Could you please try using the latest version available at the client area and check if it solves the problem at your end?

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

QSI
Newbie
Newbie
Posts: 4
Joined: Fri Mar 17, 2006 12:00 am

Post by QSI » Thu Jun 28, 2007 9:10 pm

We have upgraded to release version 2.0.2652.22325 We continue to experience this problem. Again, the problem does not appear at first but eventually the error occurs and the charts will not render without error until the IIS server is restarted. After restart, things begin working again for a few minutes until we receive the error again. These are different charts every time so I don't think it is one of the chart settings.

Any help with this error or some direction on where we might look to resolve this problem would be appreciated.

Thanks for looking.

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

Post by Narcís » Fri Jun 29, 2007 1:54 pm

Hi QSI,

Thanks for the information.

With the error information It is unclear to us if the issue is related to having TempChart property set to Session. Our suggestion is that you try setting this property to Cache, this option uses more comprehensive memory managment.

For more information about TempChart property please read Tutorial 9 - TeeChart and WebChart and ASP.NET. You'll find the tutorials at TeeChart's program group.

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

QSI
Newbie
Newbie
Posts: 4
Joined: Fri Mar 17, 2006 12:00 am

Post by QSI » Fri Jun 29, 2007 2:24 pm

Thanks for the reply. Please notice that the error occurs on this line in the above code:

Code: Select all

ChartProcessor.Export.Image.JPEG.Save(thisStream)
This happens before the jpeg is added to the Session object. At this point the TeeChart should be just producing a jpeg. Also notice that we are simply creating an image and not using the TeeChart control on the page.

QSI
Newbie
Newbie
Posts: 4
Joined: Fri Mar 17, 2006 12:00 am

Post by QSI » Tue Jul 03, 2007 4:56 pm

Any ideas on this? I was attempting to explain in our last post that we are not using this as a web control so the Cache vs Session issue doesn't apply to us. We are simply generating a jpeg image from TeeChart and then using that image on our web page. The error message occurs while generating the jpeg on the server side before being posted to the web page. Again it only happens after multiple attempts to generate the image. It works fine the first few times.

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 Jul 04, 2007 8:18 am

Hi QSI,

Sorry for the previous slightly offtrack reply, Session has been a recent area of study for us and that distracted somewhat from the essence of the error you reported. The problem as such may not be related to TeeChart's save mechanism (standard .NET Managed image save). It may be related to the server setup itself particularly if framework 1.1 and 2.0 are both present on the server. There are a few things to look at, maybe better described by support references found at general .NET support sites. eg.:

http://www.devnewsgroups.net/group/micr ... 38291.aspx
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