Does anyone know the reason why ultraChart SaveTo method is throwing ArgumentOutofRangeException?. This method has been working for three months and all of a sudden started throwing this exception. Below is my codeprivate ChartEntity GetChartImage(Infragistics.Win.UltraWinChart.UltraChart ultraChart){//generate chartMemoryStream stream = new MemoryStream();ultraChart.SaveTo(stream, System.Drawing.Imaging.ImageFormat.Png, new Size(ultraChart.Width, ultraChart.Height), new SizeF(1f, 1f));ChartEntity newEntity = new ChartEntity();newEntity.Image = Image.FromStream(stream);return newEntity;}
i'm not entirely sure, but a better argument for the resolution argument (the last one) would be new SizeF(72f, 72f).
if that doesn't fix it, please post the call stack for the exception.
Thanks. I tried the new Size but it didn't work. Here is the call stack.
The same code was working before but in a different build.
Regards,Lanre
System.ArgumentOutOfRangeException was unhandled Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" Source="mscorlib" ParamName="index" StackTrace: at System.Collections.ArrayList.get_Item(Int32 index) at Infragistics.UltraChart.Resources.Appearance.CompositeLegend.FillSceneGraph(SceneGraph scene, IChartComponent chartComponent, ChartCore core) at Infragistics.UltraChart.Core.Layers.LegendLayer.RedirectToCompositeLegend(LegendAppearance legendApp, SeriesCollection seriesCol, SceneGraph scene) at Infragistics.UltraChart.Core.Layers.IconLegendLayer.FillSceneGraph(SceneGraph scene) at Infragistics.UltraChart.Core.ChartCore.DrawChart() at Infragistics.Win.UltraWinChart.UltraChart.SaveTo(Stream stream, ImageFormat format, Size imageSize, SizeF resolution) at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.GetChartImage(UltraChart ultraChart) at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.SaveChartAndData(PerfStatChart csChart, List`1 list) at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.AddToView(Control csChart, List`1 list) at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.CreateTrendingChart(List`1 selectionList) at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.CreateTrending() at Mda.ClinicStation.Client.Common.UI.Scd.Controls.PerformanceStatus.PSViewControl.btnCreateGraph_Click(Object sender, EventArgs e) 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(Form mainForm) at Mda.ClinicStation.Client.ShellContainer.Program.Main(String[] args) in E:\CS\350\Client\Mda.ClinicStation.Client.ShellContainer\Program.cs:line 119 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()