This is a migrated thread and some comments may be shown as answers.

Divide by Zero (and it's not me)

5 Answers 182 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Kirkman
Top achievements
Rank 1
Chris Kirkman asked on 18 Jan 2019, 04:33 PM

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 

 

 

5 Answers, 1 is accepted

Sort by
0
Chris Kirkman
Top achievements
Rank 1
answered on 18 Jan 2019, 06:43 PM
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.
0
Hristo
Telerik team
answered on 21 Jan 2019, 10:43 AM
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.
0
Flower
Top achievements
Rank 1
answered on 23 Oct 2019, 09:24 AM

     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.

 


0
Flower
Top achievements
Rank 1
answered on 23 Oct 2019, 09:28 AM
It is normal before paging is used. This error occurs after using paging, but I don't know how to solve it.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Oct 2019, 09:32 AM
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.
Tags
General Discussions
Asked by
Chris Kirkman
Top achievements
Rank 1
Answers by
Chris Kirkman
Top achievements
Rank 1
Hristo
Telerik team
Flower
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or