• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
.NET Framework Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Downloads
 
 
Support
 
 
Community
 
 
Forums
 
 
 
.NET Framework Developer Center > .NET Development Forums > Windows Presentation Foundation (WPF) > System.ArithmeticException: Overflow or underflow in the arithmetic operation.
Ask a questionAsk a question
Search Forums:
  • Search Windows Presentation Foundation (WPF) Forum Search Windows Presentation Foundation (WPF) Forum
  • Search All .NET Development Forums Search All .NET Development Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerSystem.ArithmeticException: Overflow or underflow in the arithmetic operation.

  • Friday, February 29, 2008 12:55 PMbenzcpe Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    System.ArithmeticException: Overflow or underflow in the arithmetic operation.

       at System.Windows.Size..ctor(Double width, Double height)

       at System.Windows.Documents.AdornerLayer.InvalidateAdorner(AdornerInfo adornerInfo)

       at System.Windows.Documents.AdornerLayer.UpdateElementAdorners(UIElement element)

       at System.Windows.Documents.AdornerLayer.UpdateAdorner(UIElement element)

       at System.Windows.Documents.AdornerLayer.Add(Adorner adorner, Int32 zOrder)

       at System.Windows.Documents.CaretElement.EnsureAttachedToView()

       at System.Windows.Documents.CaretElement.Update(Boolean visible, Rect caretRectangle, Brush caretBrush, Boolean italic, CaretScrollMethod scrollMethod, Double scrollToOriginPosition)

       at System.Windows.Documents.TextSelection.UpdateCaretStateWorker(Object o)

       at System.Windows.Documents.TextSelection.UpdateCaretState(CaretScrollMethod caretScrollMethod)

       at System.Windows.Documents.TextSelection.EnsureCaret(Boolean isBlinkEnabled, CaretScrollMethod scrollMethod)

       at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextSelection.UpdateCaretAndHighlight()

       at System.Windows.Documents.TextEditor.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)

       at System.Windows.Controls.Primitives.TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)

       at System.Windows.UIElement.OnGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e)

       at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

       at System.Windows.Input.InputManager.ProcessStagingArea()

       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

       at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)

       at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)

       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)

       at System.Windows.Interop.HwndKeyboardInputProvider.FilterMessage(IntPtr hwnd, Int32 message, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)

       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)

       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)

       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

       at MS.Win32.UnsafeNativeMethods.IntSetFocus(HandleRef hWnd)

       at MS.Win32.UnsafeNativeMethods.SetFocus(HandleRef hWnd)

       at System.Windows.Interop.HwndKeyboardInputProvider.System.Windows.Input.IKeyboardInputProvider.AcquireFocus()

       at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)

       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)

       at System.Windows.UIElement.Focus()

       at System.Windows.FrameworkElement.OnPreviewGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)

       at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

       at System.Windows.Input.InputManager.ProcessStagingArea()

       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

       at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)

       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)

       at System.Windows.UIElement.Focus()

       at System.Windows.Forms.Integration.ElementHost.OnGotFocus(EventArgs e)

       at System.Windows.Forms.Control.WmSetFocus(Message& m)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.Integration.ElementHost.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 wparam, IntPtr lparam)

     

    Does anyone ever found this problem? It happened sometime and now I cannot reproduce it.

     

    • ReplyReply
    • QuoteQuote
     

Answers

  • Monday, March 03, 2008 5:32 AMWei Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

    I have never meet this problem except my own code defects. You can check your code to see is there any error caused this problem.

     

    Best Regards,

    Wei Zhou

    • ReplyReply
    • QuoteQuote
     
  • Thursday, March 06, 2008 6:43 PMbenzcpe Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

    Thank you for you comment.

    This happened in customer environment and they cannot reproduce it any more.

     

    I never see this error in my previous code before I convert it to WPF. Currently my application run WPF User Control base on Window ElementHost

     

    • ReplyReply
    • QuoteQuote
     

All Replies

  • Thursday, March 06, 2008 6:30 PMIfeanyi Echeruo [MSFT] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    This looks like it may be a product bug; is it possible to get some code that reproduces the crash?

     

    --Ifeanyi Echeruo [MSFT]

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, March 11, 2008 1:00 AMWilliam Baldwin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    I just had a user who had the exact same problem while using the beta version of my software.  The problem arises whenever they enter text into the "User Name" box in the login dialog window.  The only information that I could get from them is that they are operating under Vista SP1 evaluation version.  They also mentioned that they were initially using a dual display, but even after they switched back to single display the error still occurs.

     

    By the way, what exactly does "System.Windows.Size..ctor(Double width, Double height)" refer to?  The window size?

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, March 11, 2008 4:26 PMIfeanyi Echeruo [MSFT] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    There are several uses of the type so it's difficult to say where the problem lies.

     

    I believe the constructor is being passed a negative width or height but I am trying to find out if platform code was passed good inputs or bad inputs so a repro would be awful nice.

     

    --Ifeanyi Echeruo [MSFT]

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, September 16, 2008 10:59 PMT_Huynh Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    I am getting the same problem. In the application I am working on, I am calling a function from dll and from the response I want to display the information in a wpf window. Here is the summary or the app and findings so far:
     - Hybrid winform/wpf
     - The wpf window has text boxes, buttons, combo boxes
     - The wpf is just displayed using Show() without any data embedded yet
     - If the dll function is called, any control on the wpf window that allows the cursor to appear such as the text box, combo box will cause the the Arithmetic exception. The buttons however don't seems to be having any problems.
     - If the dll function is "not" called the wpf window functions correctly without the exception being raised when accessing the formentioned controls.

    I'm at a loss at why using the interop services to use a dll (not .net) would causes the wpf window to throw an arithmetic exception.
    • ReplyReply
    • QuoteQuote
     
  • Friday, May 01, 2009 4:55 PMnunyabidnizzz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    I am getting this same problem and can reproduce every time.  We have a WPF dialog with a simple text box on it.  If we open our dialog, then run a program called "Macro Express", then close Macro Express, then set focus on the text box in our dialog, it will crash every time with this stack trace.  Macro Express doesn't cause this problem with non-WPF dialogs or windows though so I think the problem must be in the WPF code somewhere. 

    Here's the code.  Create an empty WPF Application project in VS 2008, .NET 3.5 SP1.  Create 2 windows, Window1 and Window2.  Window1's "Loaded" event opens Window2 in a dialog.  Window2 has a text box.

    Window1.xaml.cs:
    public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }
            private void Shell_Loaded(object sender, RoutedEventArgs e)
            {
                Window2 dialog = new Window2();
                dialog.Owner = this;
                dialog.ShowDialog();
            }
        }



    Window1.xaml:
    <Window x:Class="EmptyDialog.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300"
        Loaded="Shell_Loaded">
        <Grid>
           
        </Grid>
    </Window>



    Window2.xaml.cs:
    public partial class Window2 : Window
        {
            public Window2()
            {
                InitializeComponent();
            }
        }


    Window2.xaml:
    <Window x:Class="EmptyDialog.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="300" Width="300">
        <StackPanel>
            <StackPanel>
                <Label  Name="lbSomeText" Content="_Some Text" />
                <TextBox Name="txtSomeText" />
            </StackPanel>
        </StackPanel>
    </Window>


    To reproduce:
    1. Run the application
    2. Start Macro Express
    3. Terminate Macro Express by clicking on it's icon in the system tray and selecting "Terminate Macro Express"
    4. Select "no" when prompted to backup macros
    5. Click on the text box in the running "Window2" xaml screen.
    6.  The application will crash with the stack trace listed in the first post of this thread.
    • ReplyReply
    • QuoteQuote
     
  • Thursday, May 07, 2009 6:36 PMJosh Couto [RobotShop] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    I'm running into the same problem.

    I have 1 button and 

    one text box

    The button will use a interop dll from Acomba (an ERP solution) the dll will execute the code fine and everything will work...
    but as soon as I click the text box after I click the button I am graced by the following error...

    System.ArithmeticException was unhandled 
    Message="Overflow or underflow in the arithmetic operation." 
    Source="WindowsBase"  StackTrace:      
           at System.Windows.Size..ctor(Double width, Double height)
           at System.Windows.Documents.AdornerLayer.InvalidateAdorner(AdornerInfo adornerInfo)
           at System.Windows.Documents.AdornerLayer.UpdateElementAdorners(UIElement element)
           at System.Windows.Documents.AdornerLayer.UpdateAdorner(UIElement element)
           at System.Windows.Documents.AdornerLayer.Add(Adorner adorner, Int32 zOrder)
           at System.Windows.Documents.CaretElement.EnsureAttachedToView()
           at System.Windows.Documents.CaretElement.Update(Boolean visible, Rect caretRectangle, Brush caretBrush, Boolean italic, CaretScrollMethod scrollMethod, Double scrollToOriginPosition)
           at System.Windows.Documents.TextSelection.UpdateCaretStateWorker(Object o)
           at System.Windows.Documents.TextSelection.UpdateCaretState(CaretScrollMethod caretScrollMethod)
           at System.Windows.Documents.TextSelection.EnsureCaret(Boolean isBlinkEnabled, CaretScrollMethod scrollMethod)
           at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextSelection.UpdateCaretAndHighlight()
           at System.Windows.Documents.TextEditor.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
           at System.Windows.Controls.Primitives.TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
           at System.Windows.UIElement.OnGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e)
           at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
           at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
           at System.Windows.Input.InputManager.ProcessStagingArea()
           at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
           at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
           at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
           at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)
           at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
           at System.Windows.UIElement.Focus()
           at System.Windows.Documents.TextEditorMouse.MoveFocusToUiScope(TextEditor This)
           at System.Windows.Documents.TextEditorMouse.OnMouseDown(Object sender, MouseButtonEventArgs e)
           at System.Windows.Controls.Primitives.TextBoxBase.OnMouseDown(MouseButtonEventArgs e)
           at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
           at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
           at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
           at System.Windows.Input.InputManager.ProcessStagingArea()
           at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
           at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
           at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
           at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.Run()
           at System.Windows.Application.RunDispatcher(Object ignore)
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
           at PMC.App.Main() in E:\Projects\WPF\PMC\PMC\obj\Debug\App.g.cs:line 0
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:


    Does WPF Not like using Interop Dlls? is there a work around?

    thanks,
    Josh
    www.RobotShop.com
    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement