I have been developing an add on with C# and WPF to an application.
It's been working fine until launched on a Win7 machine. The symptoms are that a Microsoft .NET Framwork's "Unhandled exception" dialog pops up on startup for System.ArithmeticException (Overflow or underflow in the arithmetic operation) and gives a stack trace pointing to System.Windows.Controls.Primitives.Track.ComputeScrollBarLengths (...)
and deeper.
So, I began to debug the app: it showed that System.ArithmeticException was thrown when setParent from user32.dll was called. This is done when the application makes a call to show the add-on UI.
public bool ShowUI(int Parent)
{
userControl = new MyUserControl(); // Extends System.Windows.Forms.UserControl
SetParent(userControl.Handle, new IntPtr(Parent)); // <- exception thrown here
...
}
What would possibly be causing this issue?