Divide by Zero (and it's not me)

6 posts, 0 answers
  1. Chris Kirkman
    Chris Kirkman avatar
    101 posts
    Member since:
    Apr 2010

    Posted 18 Jan 2019 Link to this post

    We're getting a Divide by Zero exception from one of the Telerik components.  We can't track it down.

    We create an instance of a COM component which is an old COM dll.  Any time we try to open a form with Telerik controls on it the application crashes with a StackOverflow exception.  I've attached the stack.  This is a really high priority item for us at this point and holding up our release.  :(

    Additionally, we can create an instance of the COM component in a test application without any problems whatsoever.

     

    ************** Exception Text **************
    System.DivideByZeroException: Attempted to divide by zero.
       at Telerik.WinControls.UI.RadCommandBarItemsPanel.ArrangeOverride(SizeF arrangeSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.CommandBarStripElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.CommandBarRowElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.Layouts.StackLayoutPanel.ArrangeOverride(SizeF arrangeSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.LightVisualElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.UI.RadCommandBarElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.RootRadElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RootRadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.RadElementTree.PerformInnerLayout(Boolean performMeasure, Int32 x, Int32 y, Int32 width, Int32 height)
       at Telerik.WinControls.RadControl.OnLoad(Size desiredSize)
       at Telerik.WinControls.UI.RadCommandBar.OnLoad(Size desiredSize)
       at Telerik.WinControls.RadControl.LoadElementTree(Size desiredSize)
       at Telerik.WinControls.RadControl.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at Telerik.WinControls.UI.RadFormControlBase.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.Callback(IntPtr hWnd, Int32 msg, IntPtr 

     

     

  2. Chris Kirkman
    Chris Kirkman avatar
    101 posts
    Member since:
    Apr 2010

    Posted 18 Jan 2019 Link to this post

    Looks like I may have finally resolved it.  The COM component when loaded on the same thread as my app just plain failed.  When I started it in it's own background thread, that equally failed.  We found that starting it on it's own thread and then setting its state to STA did the trick.
  3. Hristo
    Admin
    Hristo avatar
    1520 posts

    Posted 21 Jan 2019 Link to this post

    Hi Chris,

    Errors in the layout can be caused by multithreading in the UI thread. The following MSDN resource discusses multithreading in WinForms: https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/multithreading-in-windows-forms-controls. The call stack suggests that the error is being raised while executing the layout. This logic is at a very base level and an error there can mean that the application is an invalid state. 

    We are not aware of an issue when mixing the controls with COM components. As I understand you have managed to resolve the issue. In case you would like us to test a sample application with the COM dll, please send it over. For that purpose, you can use the ticketing system which is a private channel for communication.

    Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Flower
    Flower avatar
    2 posts
    Member since:
    Oct 2018

    Posted 23 Oct 2019 in reply to Hristo Link to this post

         Hello, I also encountered the same problem:

     

         private void btn_Click(object sender, EventArgs e)
            {

                Button btn = sender as Button;
                Menu menu = btn.Tag as Menu;
               
                 Form form = (Form)IocManager.Resolve(Type.GetType(menu.FormName));
                 form.Tag = menu;
                 form.MdiParent = AppInfo.fMdiMain;
                 form.StartPosition = FormStartPosition.CenterScreen;
                  //form.WindowState = FormWindowState.Maximized;
                 form.Show();     //This step gives an error.           
            }

     

    When my project first runs, click the button to open another form, then load the radgridview binding data, and the page will display this error. When I click the button a second time, everything works fine, I don't know how to solve it.

     


  5. Flower
    Flower avatar
    2 posts
    Member since:
    Oct 2018

    Posted 23 Oct 2019 in reply to Hristo Link to this post

    It is normal before paging is used. This error occurs after using paging, but I don't know how to solve it.
  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 24 Oct 2019 Link to this post

    Hello, Flower,       

    According to the provided information, it is not clear what causes the error message on your end. That is why I have prepared a sample project following the code snippet from your post. Please refer to the attache zip file. The behavior on my end is illustrated in the gif file. Am I missing something? Could you please specify the exact steps how to reproduce the problem with my sample project?  

    Alternatively feel free to submit a support ticket from your Telerik account and provide a sample project demonstrating the error you are facing. Thus, our support staff will gladly assist you. Thank you in advance for your cooperation.

    I am looking forward to your reply.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top