Printing large data (chart) in Silverlight 4 (Error on line ei=ImageExtensions.ToImage(UIElement))

Dec 3, 2011 at 6:27 AM

Hi All,

I have created web application which uses:

1. Silverlight 4 (Project)

2. Web site project to launch chart

3. RIA WCF service

The base xmal file is collection of multiple user controls contains main chart at the left, list at the right etc. Now what has been done is, the part which is getting shown in the chart portion should get printed when clicked on the Print button. Currently printing is working fine if the chart contains small amount of data.

But when that chart grows and contains large amount of data it stops working. The line which fails to process request is:

ei = ImageExtensions.ToImage(SP); //’ SP is stack panel control

 Then I put log file to track what’s wrong and I got the error as:

 StackTrace:   at System.Windows.Media.Imaging.WriteableBitmap.AllocPixelBuffer()

   at System.Windows.Media.Imaging.WriteableBitmap..ctor(UIElement element, Transform transform)

   at ImageTools.ImageExtensions.ToImage(UIElement element)

   at OrgChartSilverLight.ChartActions.ActionPrint()

 Error Message: Exception of type 'System.OutOfMemoryException' was thrown

Is there any setting that needs to be checked or set to handle large data printing in Silverlight 4?

Any  help in this regards would be really appreciated.

Thanks in advanced.

Have a nice day!