Chart causing C# SaveFileDialog to hang...

Posted by: lars-fp on 8 September 2017, 2:39 pm EST

  • Posted 8 September 2017, 2:39 pm EST

    <p>I ran into a strange bug (C#) in which a call to SaveFileDialog.ShowDialog() - a native C# call - on a particular form causes my program to hang.   One by one, I eliminated other elements on the form, until I've narrowed it down the the presence of a Chart on the form.    If I delete the chart from the form, the SaveFileDialog.ShowDialog() opens fine and my program works.   If the chart is on the form, the SaveFileDialog.ShowDialog() hangs my program.</p><p> The SaveFileDialog is not interacting with the chart in any way.  No data is shared or accessed.</p><p> Has anyone else run into this problem?   Seems like a potential FarPoint bug.</p><p> Thanks. <br></p><p> _ Lars <br></p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>I've narrowed this down to a very simply use case.</p><p>Create a form with the following elements:</p>
      <p class='content-list-item'>A button that when clicked triggers a SaveFileDialog.ShowDialog()</p><p class='content-list-item'>A System.Windows.Forms.Panel</p><p class='content-list-item'>A Spread Chart inside the panel <br></p>
    <p> If the Chart "Dock" property is set to "Fill" the SaveFileDialog.ShowDialog() call will hang the application when the button is clicked</p><p> If the "Dock" property is set to "Node" is work fine.</p><p> <br></p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hmm... Docking may have been a red herring (although it seemed to fix my other test case ).  </p><p>When I set docking of the chart in your sample solution to "none", the application still hangs upon pressing of the button.  However, if I delete the chart from the solution it works just fine. <br></p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Strange.  It replicates consistently on multiple machines here.    Are you running the code above in the constructor in your form?  </p><p> </p><p> We have a successful workaround now - namely removing the "AddRange' code from the auto-generated code in Visual Studio and later running the "AddRange" code outside the form constructor.  Then it seems to work fine.<br></p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hello,</p><p>I used the following code and it still worked fine for me, no freezing an no exception happens , I am using Windows 7 32 bit and VS2010.</p><p> fpChart1.Location = new System.Drawing.Point(18, 43);<br><br>            // Comment these two lines out and it works<br>            FarPoint.Win.Chart.YPlotArea yPlotArea1 = new FarPoint.Win.Chart.YPlotArea();<br>            fpChart1.Model.PlotAreas.AddRange(new FarPoint.Win.Chart.PlotArea[] { plotArea });<br><br>            fpChart1.Name = "chart";<br>            fpChart1.Size = new System.Drawing.Size(60, 58);<br>            fpChart1.TabIndex = 36;<br>            fpChart1.Text = "chart"; </p><p> </p><p>Thanks,</p><p> </p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Broke your sample project down further into a version that works and one that doesn't.   In the example below, instead of adding the chart in the designer, I add it in code.   If I don't add a range to the chart, SaveFileDialog works file (i.e. remove the two lines in red).   If these lines are present SaveFileDialog hangs.<br></p><p> </p><blockquote><p>    <i>public partial class Form1 : Form<br>    {<br>        private FarPoint.Win.Chart.FpChart chart = new FarPoint.Win.Chart.FpChart(); <br><br>        public Form1()<br>        {<br>            InitializeComponent();<br><br>            this.Controls.Add(chart);<br>           <br>            chart.Location = new System.Drawing.Point(18, 43);<br><br>            // Comment these two lines out and it works<br>            <font color="#990033">FarPoint.Win.Chart.YPlotArea yPlotArea1 = new FarPoint.Win.Chart.YPlotArea();<br>            chart.Model.PlotAreas.AddRange(new FarPoint.Win.Chart.PlotArea[] { yPlotArea1 });</font><br><br>            chart.Name = "chart";<br>            chart.Size = new System.Drawing.Size(60, 58);<br>            chart.TabIndex = 36;<br>            chart.Text = "chart";<br>        }<br><br><br>        private void button1_Click(object sender, EventArgs e)<br>        {<br>            saveFileDialog1.ShowDialog();    // Hangs if red lines above are not commented out<br>        }<br>    }</i> <br></p></blockquote>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Thank you for putting together a test project.    Your attached sample shows the same hanging behavior when I run it on my computer.   I'm also using VS2010 and Spread 5.0.3518.2008.</p><p>I'm trying to think what else could be different between our systems.   I'm running Windows 7.   You? <br></p><p>  <br></p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hello,</p><p>Yes, i was using the code same exact way as, you showed in your example. I am using a 32 bit Windows 7 machine , do you have a 64 bit machine?</p><p> </p><p>Thanks,</p><p> </p>
  • Replied 8 September 2017, 2:39 pm EST

    Also note that if I delete the chart and replace it an FPSpread it also works fine.<br>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hello,</p><p>I am not able to replicate this issue at my end. I have created a sample which is attached with this post please test the same and let me know if you can still recreate this issue. I am using Spread 5.0.3518.2008 and VS2010.</p><p>Thanks,</p><p> </p>
    2011/06/ChartSaveFileDialog.zip
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hello,</p><p>I have tested this issue with VS2010 and Windows 7 64 bit still no exception or freezing happens at my end for the application. I have used the same code as posted by you in one of the earlier posts. Could you please post a small sample application for us to debug with this environment where I can replicate this issue. I have used VS2010 v10.0.30319.1 with .Net Framework 4.0.30319 and Windows 7 64 bit.</p><p> </p><p> </p><p>Thanks, <br></p><p> </p>
  • Replied 8 September 2017, 2:39 pm EST

    <p>Hello, <br></p><p>I tested this code with VS2008 and Widows 7 64 bit it seems to be not creating any problem, I will test it with VS2010 also and will let you know.</p><p> </p><p>Thanks,</p><p> </p>
  • Replied 8 September 2017, 2:39 pm EST

    Yes, 64 bit.<br>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels