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

    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.

     The SaveFileDialog is not interacting with the chart in any way.  No data is shared or accessed.

     Has anyone else run into this problem?   Seems like a potential FarPoint bug.

     Thanks.

     _ Lars

  • Replied 8 September 2017, 2:39 pm EST

    I've narrowed this down to a very simply use case.

    Create a form with the following elements:

      A button that when clicked triggers a SaveFileDialog.ShowDialog()

      A System.Windows.Forms.Panel

      A Spread Chart inside the panel

     If the Chart "Dock" property is set to "Fill" the SaveFileDialog.ShowDialog() call will hang the application when the button is clicked

     If the "Dock" property is set to "Node" is work fine.

     

  • Replied 8 September 2017, 2:39 pm EST

    Hmm... Docking may have been a red herring (although it seemed to fix my other test case ). 

    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.

  • Replied 8 September 2017, 2:39 pm EST

    Strange.  It replicates consistently on multiple machines here.    Are you running the code above in the constructor in your form?  

     

    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.

  • Replied 8 September 2017, 2:39 pm EST

    Hello,

    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.

     fpChart1.Location = new System.Drawing.Point(18, 43);

                // Comment these two lines out and it works
                FarPoint.Win.Chart.YPlotArea yPlotArea1 = new FarPoint.Win.Chart.YPlotArea();
                fpChart1.Model.PlotAreas.AddRange(new FarPoint.Win.Chart.PlotArea[] { plotArea });

                fpChart1.Name = "chart";
                fpChart1.Size = new System.Drawing.Size(60, 58);
                fpChart1.TabIndex = 36;
                fpChart1.Text = "chart";

     

    Thanks,

     

  • Replied 8 September 2017, 2:39 pm EST

    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.

     

        public partial class Form1 : Form
        {
            private FarPoint.Win.Chart.FpChart chart = new FarPoint.Win.Chart.FpChart();

            public Form1()
            {
                InitializeComponent();

                this.Controls.Add(chart);
              
                chart.Location = new System.Drawing.Point(18, 43);

                // Comment these two lines out and it works
                FarPoint.Win.Chart.YPlotArea yPlotArea1 = new FarPoint.Win.Chart.YPlotArea();
                chart.Model.PlotAreas.AddRange(new FarPoint.Win.Chart.PlotArea[] { yPlotArea1 });


                chart.Name = "chart";
                chart.Size = new System.Drawing.Size(60, 58);
                chart.TabIndex = 36;
                chart.Text = "chart";
            }


            private void button1_Click(object sender, EventArgs e)
            {
                saveFileDialog1.ShowDialog();    // Hangs if red lines above are not commented out
            }
        }

  • Replied 8 September 2017, 2:39 pm EST

    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.

    I'm trying to think what else could be different between our systems.   I'm running Windows 7.   You?

     

  • Replied 8 September 2017, 2:39 pm EST

    Hello,

    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?

     

    Thanks,

     

  • 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.
  • Replied 8 September 2017, 2:39 pm EST

    Hello,

    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.

    Thanks,

     


    2011/06/ChartSaveFileDialog.zip
  • Replied 8 September 2017, 2:39 pm EST

    Hello,

    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.

     

     

    Thanks,

     

  • Replied 8 September 2017, 2:39 pm EST

    Hello,

    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.

     

    Thanks,

     

  • Replied 8 September 2017, 2:39 pm EST

    Yes, 64 bit.
Need extra support?

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

Learn More

Forum Channels