Flex chart -- strange error basic questions about it's behaviour

Posted by: a.sharov on 24 June 2022, 2:47 am EST

    • Post Options:
    • Link

    Posted 24 June 2022, 2:47 am EST

    Hi.

    Consider code in attachement:

    1)Why I got exceptions when click on error and error2 buttons? If I add the very same data after chart is loaded and visible everything is fine (press ok button then show points btn).

    1. Basic questoin about exception handling – why I can’t catch OverflowException in my code. I just see “Exception thrown: ‘System.OverflowException’ in System.Drawing.dll” output window but my exc. handlers are not activated.

    Thanks in advanceC1ChartTest.zip

  • Posted 26 June 2022, 7:50 pm EST

    Hi,

    Thanks for the sample.

    1. Hi, You’re getting these exceptions because of adding same items in SortedList. JFYI, SortedList store items in Key-Value pairs where key shouldn’t duplicate in list. In your scenario, after adding same item into the SortedList the duplicate key won’t add and it will throws Exception . You need to add item in SortedList with a key which is not existed in list.

      Note:- Each key must different in SortedList

    2. There are similar queries are posted on MSDN. But we need to figure out first, that how you are using Classes and Methods of System.Drawing.dll.

      In the provided sample we didn’t get this issue. Could you please provide a small sample to replicate this behavior. So, that we can assist you accordingly.

    Best Regards,

    Nitin

  • Posted 26 June 2022, 11:58 pm EST - Updated 3 October 2022, 1:23 pm EST

    Hi.

    Sorry, probably I was not clear. There is 3 buttons with basically the same behaviour adding same data. When you click on “ok” button then empty chart is displayed, you then click “show points” button and see data, eveything is fine. Both error btns click follows the same pattern except that I initially add data and try to show chart (with added data) and then exception is raised (Exception thrown: ‘System.OverflowException’ in System.Drawing.dll). Put it simply, on my desktop I see attached image and message in output window(Exception thrown: ‘System.OverflowException’ in System.Drawing.dll)

    I uploaded modified version of my example which removes “show points” btn in case of “error” or “error2” btn clicked to remove confusion. Of course there will be exception because this data is already added. It is just for demonstation purposes.

    Put iit simple, given code:

    
     public Form1(bool add=false)
            {
                InitializeComponent();
                chartUserControl2.ComponentName = "X";
                if (add) AddPos();
            }
    
            public void AddPos()
            {
                 chartUserControl2.AddPositions(_pos);
            }
    
    .....
    
      private void okButton_Click(object sender, EventArgs e)
            {
                var f1 = new Form1();
                f1.Show();  [b]//then call show btn and everything is ok[/b]
                
            }
    
            private void errButton_Click(object sender, EventArgs e)
            {
                var f1 = new Form1(true);
                f1.showPointsBtn.Visible = false;
                try
                {
                    f1.Show(); [b]//I see attached image[/b]
                }
                catch(Exception exception)
                {
                    Debug.WriteLine(exception);
                }
            }
    
            private void err2Button_Click(object sender, EventArgs e)
            {
                var f1 = new Form1();
                f1.showPointsBtn.Visible = false;
                try
                {
                    f1.Show();
                    f1.AddPos(); [b]//I see attached image[/b]
                }
                catch(Exception exception)
                {
                    Debug.WriteLine(exception);
                }
            }
    
    
    
    

    Does it make sense now?

    My flex chart version is 4.5.20211.492 (and all other c1 controls).

    C1ChartTest.zip

  • Posted 27 June 2022, 7:01 pm EST

    Anyone?

  • Posted 27 June 2022, 7:35 pm EST - Updated 3 October 2022, 1:24 pm EST

    Hi,

    Apologize for the delay in response.

    We have replicated this issue at our end. We are getting unhandled Exception: OverflowException in System.Drawing.

    However, there is no such type of exception occurring in latest 4.5.2 build i.e., 4.5.20221.557 version.(see Gif)

    So, we suggests you to upgrade to the latest 4.5.2 build to resolve this issue on your project.

    JFYI, the startup project should contain C1 assemblies, if another project(containing C1 controls) is referenced.

    Please refer the attached sample(latest C1 assemblies updated): C1ChartTest_Mod.zip

    Best Regards,

    Nitin.

  • Posted 29 June 2022, 3:53 am EST

    Thank you, Nitin. Seems to be that upgrade to new version fixes this problem, so I will mark this thread as solved. But could you, please, explain about exception handling part,

    namely:

    2) Basic questoin about exception handling – why I can’t catch OverflowException in my code. I just see “Exception thrown: ‘System.OverflowException’ in System.Drawing.dll” output window but my exc. handlers are not activated.

    I add following code to Program.cs:

     Application.ThreadException += Application_ThreadException;
    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
    
    

    and able to handle this exception in Application_ThreadException method. But why it ignores my catch handlers (see in my code above for example)? Is it swallowed before it reached my catch region but how then I can handle it in my Application_ThreadException? Seems weired to me, what I’m missing?

  • Posted 29 June 2022, 5:03 pm EST

    Hi,

    Thanks for upgrading to the latest 4.5.2 version.

    The exception is occurred while rendering the Flexchart which is internal and throws after the window is loaded and Flexchart is rendering. It doesn’t swallows before reaches to catch region. It throws exception after passing the catch region hence on rendering flexchart.

    Whereas, in latest version, Flexchart is successfully rendered on a new window without having issue in graphics while rendering.

    Regards,

    Nitin.

  • Posted 29 June 2022, 11:57 pm EST

    Thank you, Nitin for your explanation. But still this behaviour makes no sense to me. I’ve change code above to

    
               try
                {
                    f1.ShowDialog(); 
                }
                catch(Exception exception)
                {
                    Debug.WriteLine(exception);
                }
    
    

    So, control flow is blocked till chart is closed and we still in try region. There is only one thread (GUI) and yet catch logic is not triggered. Mystic.

  • Posted 1 July 2022, 12:36 am EST

    Would be really thankful if someone can clarify this basic misunderstanding of control behavior and exception handling, why it is unobserve my code above?..

  • Posted 1 July 2022, 1:44 am EST - Updated 3 October 2022, 1:24 pm EST

    Hi,

    Apologize for the delay in response.

    JFYI, Flexchart also uses another thread for rendering. Also, we are getting the exception on ShowDialog(), this is replicable at our end.(see attached gif)

    Regards,

    Nitin

Need extra support?

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

Learn More

Forum Channels