Jump to content
Software FX Community

Why do I get "Parameter is not valid"


wwwz
 Share

Recommended Posts

I got this error when drawing a chart. but it can't be reproducted, just occasionally occured. Why? Anyone can help?

EXCEPTION!-----------------------

[Parameter is not valid.]

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)

at ChartFX.WebForms.Internal.v.a(Graphics A_0, Int32 A_1, Int32 A_2)

at ChartFX.WebForms.Internal.i.b(OutputText A_0, OutputInfo A_1)

at ChartFX.WebForms.Chart.a(Stream A_0, IOutputWriter A_1, OutputText A_2, OutputText A_3, OutputInfo A_4)

at ChartFX.WebForms.Chart.a(OutputText A_0, OutputText A_1, Boolean A_2, String A_3, String A_4)

at ChartFX.WebForms.Chart.Render(HtmlTextWriter output)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at ASP.rum_common_control_performance_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Control.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)

at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at ASP.rum_chart_chartresults_aspx.__RenderContent1(HtmlTextWriter __w, Control parameterContainer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Control.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Control.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Page.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

END EXCEPTION--------------------

 

Link to comment
Share on other sites

Looks like a bug. However more details are needed in order to determine the cause of it (meaning a repro case).

I would focus on the width and height of the chart at the time of rendering. Are you doing any code that may assign say negative values to these properties?

Link to comment
Share on other sites

All the code handling Chart is listed below. 

In my A.aspx: 

 ......

<div id ="divChartAndTable" runat ="server">

<div id="chartbox" runat="server" class="chartbox">

<div id="divChartImage" runat="server"></div>

<chartfx7:Chart ID="chartResponseTime" runat="server" Width="839px" Height="400px" PlotAreaColor="White" >

<SpecialObjects>

<chartfx.webforms.adornments.simpleborder assemblyname="ChartFX.WebForms.Adornments"

color="153, 153, 153"></chartfx.webforms.adornments.simpleborder>

<chartfx.webforms.adornments.solidbackground assemblyname="ChartFX.WebForms.Adornments"

color="204, 204, 204"></chartfx.webforms.adornments.solidbackground>

  </SpecialObjects>

  <AxisY>

  <Grids Major-Style="Solid" Major-Color="204, 204, 204"/>

  </AxisY>

  <AxisX>

  <Grids Major-Style="Solid" Major-Color="204, 204, 204"/>

  </AxisX>

  <LegendBox ContentLayout="Near" BackColor="White" Border="External">

  </LegendBox>

  <AllSeries MarkerSize="2"></AllSeries>

  </chartfx7:Chart>

 </div>

......

in my A.cs  

 protected void Page_Load(object sender, EventArgs e)

  {

......

  ReadChartData(strSelectItem);  

 getChartStyle(strSelectItem);

 BindData(strSelectItem); //no operation of Chart

SetChartHeight(chartResponseTime,IsPrint);

......

  }

 

private void getChartStyle(string value)

  {

  chartResponseTime.AxisY.LabelsFormat.Decimals = 3;

  chartResponseTime.LegendBox.CustomItems.Clear();

  // Now let's hide the standard Legend Box Items

  LegendItemAttributes legendItem = new LegendItemAttributes();

  legendItem.Visible = true;

  this.chartResponseTime.LegendBox.ItemAttributes[chartResponseTime.Series] = legendItem;

 

  string strShowName = "";

  if (value == "Page Load")

  {

  strShowName = "Load Time";

  }

  else

  {

  strShowName = value;

  }

  //string maskString = string.Format("%l\n%s\n" + strShowName + ": %v\nMeasurement count: %L");

  string maskString = string.Format("%l\n%s\n" + strShowName + ": %v\nMeasurement count: %L");

  chartResponseTime.ToolTipFormat = maskString;

  if (chartResponseTime.AxesX.Count > 1)

  {

  chartResponseTime.AxesX.RemoveAt(1);

  }

  chartResponseTime.Gallery = Gallery.Lines;

  chartResponseTime.LegendBox.Dock = DockArea.Bottom;

  chartResponseTime.LegendBox.ContentLayout = ContentLayout.Spread;

  chartResponseTime.AxisY.Title.Text = "seconds";

  chartResponseTime.AxisY.Title.Alignment = StringAlignment.Center;

  chartResponseTime.AxisX.LabelsFormat.Format = AxisFormat.DateTime;

  chartResponseTime.AxisX.LabelAngle = 90;

  chartResponseTime.AxisX.Visible = true;

  chartResponseTime.LegendBox.Visible = true;

  chartResponseTime.AxisX.Grids.Major.Visible = true;

  //shield Chart Menu's right mouse

  chartResponseTime.ContextMenus = false;

  //when there are many legend values, the drawing area is too small, the opposite gaps (e.g. top and bottom) are different or the legend is not centered

  chartResponseTime.LegendBox.AutoSize = true;

  //Allows the legend box margins to go outside of the chart's drawing area.

  chartResponseTime.LegendBox.PlotAreaOnly = false;

  string url = Request.Url.ToString();

  //if (url.IndexOf("PrintChart.aspx") == -1 || url.IndexOf("EmailChart.aspx") == -1)

  ////if (url.IndexOf("PrintChart.aspx") == -1)

  //{

  SetSeriesLink(value);

  //}

  }

private void ReadChartData(string value)

  {  

  chartResponseTime.DataSourceSettings.Fields.Clear();

  responseTable = ds.Tables["ResponseTimes"];

  chartResponseTime.DataSourceSettings.DataSource = responseTable;

  chartResponseTime.DataSourceSettings.Fields.Add(new FieldMap("Time", FieldUsage.Label));

  if (responseTable.Rows.Count > 0)

  {

  string strColumn;

  System.Drawing.ColorConverter wcc = new WebColorConverter();

  List<string> colors = GetChartColors(responseTable.Columns.Count - 1);

  List<MarkerShape> ChartShape = new List<MarkerShape>();

  ChartShape = ChartCommon.ChartMarkerShape();

  for (int i = 1; i < responseTable.Columns.Count; i++)

  {

  strColumn = responseTable.Columns.ColumnName.ToString();  

  chartResponseTime.DataSourceSettings.Fields.Add(new FieldMap(strColumn, FieldUsage.Value));

  string columnName = responseTable.Columns.ColumnName.ToString();

  chartResponseTime.Series[i - 1].Text = columnName;

  System.Drawing.Color c = (Color)wcc.ConvertFromString(colors[i - 1]);

  chartResponseTime.Series[i - 1].Color = c;

  chartResponseTime.Series[i - 1].MarkerShape = ChartShape[(i - 1) % ChartShape.Count];

  if (responseTable.Columns.Caption.IndexOf("comparison=1") != -1)

  {

  this.chartResponseTime.Series[i - 1].Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;

  for (int k = 1; k < responseTable.Columns.Count; k++)

  {

  if (IsTheSameProjectOrPage(responseTable.Columns.Caption, responseTable.Columns[k].Caption))

  {

  //the color of two suitable pages or projects are the same

  //chartResponseTime.Series[i - 1].Color = chartResponseTime.Series[k - 1].Color;

  chartResponseTime.Series[i - 1].MarkerShape = chartResponseTime.Series[k - 1].MarkerShape;

  }

  }

  }

  }

  //the data of per point in the chart

  DataTable dtResponseData = new DataTable();

  dtResponseData = ds.Tables["ResponseTimesData"];

  for (int s = 0; s < this.chartResponseTime.Series.Count; s++)

  for (int k = 0; k < responseTable.Rows.Count; k++)

  {

  if (chartResponseTime.Series.Text == dtResponseData.Columns[s + 1].ColumnName)

  {

  chartResponseTime.Points[s, k].Text = dtResponseData.Rows[k][s + 1].ToString();

  }

  }

  }

  else

  {

  chartResponseTime.Data.Clear();

  }

  bool havedData = false;

  double Max = 0;

  for (int j = 1; j < responseTable.Columns.Count; j++)

  for (int k = 0; k < responseTable.Rows.Count; k++)

  {

  if (responseTable.Rows[k][j] != System.DBNull.Value)

  {

  double data = Convert.ToDouble(responseTable.Rows[k][j]);

  if (data > 0)

  {

  havedData = true;

  if (Max < data)

  {

  Max = data;

  }

  }

  }

  }

  if (!havedData)

  {

  for (int i = 0; i < chartResponseTime.AxesY.Count; i++)

  {

  chartResponseTime.AxesY.Max = 1;

  chartResponseTime.AxesY.Min = 0;

  chartResponseTime.AxesY.Step = 1;

  }

  }

  else

  {

  for (int i = 0; i < chartResponseTime.AxesY.Count; i++)

  {

  chartResponseTime.AxesY.Max = Max;

  chartResponseTime.AxesY.Min = 0;

  chartResponseTime.AxesY.Step = 0;

  }

  chartResponseTime.RecalculateScale();

  }

  setKeyLabelForChart(chartResponseTime, responseTable);

  }

 

 

 

public static void SetChartHeight(ChartFX.WebForms.Chart chartContorl,bool isPrint)

  {

  int maxlen = 0;

  for (int i = 0; i < chartContorl.Series.Count; i++)

  {

  if (chartContorl.Series.Text.Length > maxlen)

  {

  maxlen = chartContorl.Series.Text.Length;

  }

  }

  if (maxlen == 0)

  return;

  int legCol = 125 / maxlen;

  if (isPrint)

  legCol = 82 / maxlen;

  if (legCol == 0)

  legCol = 1;

  int legendHeight = chartContorl.Series.Count / legCol * 25 + 25;

  if (chartContorl.Series.Count % legCol != 0)

  {

  legendHeight += 25;

  }

  chartContorl.LegendBox.Height = legendHeight;

  chartContorl.Height = legendHeight + 350;

  }

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...