locked
System.ArithmeticException: Overflow or underflow in the arithmetic operation. RRS feed

  • Question

  • 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.

     

    Friday, February 29, 2008 12:55 PM

Answers

  • 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

    Monday, March 3, 2008 5:32 AM
  • 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

     

    Thursday, March 6, 2008 6:43 PM

All replies

  • 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

    Monday, March 3, 2008 5:32 AM
  • This looks like it may be a product bug; is it possible to get some code that reproduces the crash?

     

    --Ifeanyi Echeruo [MSFT]

    Thursday, March 6, 2008 6:30 PM
  • 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

     

    Thursday, March 6, 2008 6:43 PM
  • 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?

    Tuesday, March 11, 2008 1:00 AM
  • 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]

    Tuesday, March 11, 2008 4:26 PM
  • 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.
    Tuesday, September 16, 2008 10:59 PM
  • 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.
    Friday, May 1, 2009 4:55 PM
  • 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
    Thursday, May 7, 2009 6:36 PM
  • Hi,

    I'm having a similar problem.

    Here is my system description:

    Windows XP SP3
    .Net Framework 3.5 SP1


    I have a pure unmanaged MFC application that displays child windows (CMDIChildWnd). The MFC application does not have /clr enabled. I have a wrapper class in a dll that has /clr enabled that instantiates WPF controls and uses HwndSource to get the control's handles. The MFC application creates instances of this wrapper class and uses the handles to present the WPF controls.

    I've created several prototype applications and they all seem to work. However, they don't use the wrapper class. All sample code that I've found on the web seem to set /clr on the MFC application and uses HwndSource directly from it.

    The exception I'm getting is similar to the ones posted here but it comes when my wrapper class tries to instantiate any of my WPF controls. I debugged and stepped in to the constructor of my WPF control and the exception seems to come from the parsing of my XAML.

    Does anyone know what could cause this exception when using a interop dll?

    I really want to keep my MFC application the way it is and use the wrapper class to deal with the WPF controls.

    Thank you,
    Marcos





    Tuesday, July 7, 2009 6:57 PM
  • Hi there,

    I've had exactly the same problem I created a WPF UI exposed it through a Com Interface which is then called from Delphi.

    I've noticed that something is wrong when I got the following exception: 'Maximized' value cannot be assigned to property 'WindowState' of object 'Project.SomeView'. Overflow or underflow in the arithmetic operation. When I removed the property it moved to the next property same exception again and again, this continued until I decided to wrap the InitializeComponent() method with a try catch, and looked at all the inner exceptions.

    I've resolved the problem by including the following API.
    [DllImport( "msvcr70.dll", CallingConvention = CallingConvention.Cdecl )]
    public static extern int _fpreset();

    More information about the API can be found here

    In my constructor just before the InitializeComponent() method I've added the following line

    // Reset the Floating Point
    _fpreset();
    
    

    So in the end my constructor looked like this:

    public SomeView()
    {
      // Reset the Floating Point (When called from External Application there was an Overflow exception)
      _fpreset();
    
      // Initialize the Component
      InitializeComponent();
    }

    This resolved my problem completely hope this can resolve your problems as well.

    Regards,

    Johan J v Rensburg
    Thursday, October 8, 2009 7:04 AM
  • Hi, just to follow up on the previous post by JohanJvR.

    I was just thinking that a pseudo code example would benefit the discussion. I just pasted some lines from my project...

    In this case I have a controller that initiates a connection using unmanaged code to a third party device. After the connection a WPF window is shown. Notice the late call to _fpreset! The point is that - in my case - the ArithmeticException is thrown when the window is shown and not when created.

    ******************
    //Call unmanaged code
    MedialonController.CreateInstance(ipAddress, MedialonSettings.Default.PublicGroup);

    //Create a WPF window
    this._wellcomeWindow = new WelcomeWindow();
    .
    .
    .
    .
    //Reset the floating point
    _fpreset();

    //If the _fpreset is not called then a System.ArithmeticException is thrown when the window is shown.
    this._wellcomeWindow.Show();
    ******************

    Hope it helps!
    Cheers
    Friday, October 9, 2009 8:11 AM
  • FYI... I also getting this exception.  I have a wpf project that is trying to use a com video capture component in a WindowsFormHost control.   
    The code works fine until it try to click on a button or resized the window.

    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.Input.KeyboardNavigation.ShowFocusVisual(DependencyObject element)
           at System.Windows.Input.KeyboardNavigation.ShowFocusVisual()
           at System.Windows.FrameworkElement.OnGotKeyboardFocus(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.ReevaluateFocusCallback(Object arg)
           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.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(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 ScreenCaptureClient.App.Main() in C:\src\ClassroomCaptureSystem 1.0\ScreenCaptureClient\obj\x86\Debug\App.g.cs:line 0
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
           at System.Activator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           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:

    Tuesday, January 12, 2010 4:59 PM
  • Hello Johan,

    I'm experiencing the same exception. In my application I'm referencing a third-part COM component and when I instantiate it i my main windows, I got the exception. The strange thing is that if I remove the WindowState = Maximized property and set it to a specifc size, the problem does not occurs.

    Looking at your proposed solution, could you please tell me where can I get the msvcr70.dl from?

    Kindly Regards,

    Igor.

    Project Manager at INOVATIVA Tecnologia www.inovativatec.com
    Tuesday, March 2, 2010 3:59 PM
  • Hi Igor,

    It's in the Windows\System32 folder you don't need to add the dll to your project. You just have to use the API reference.

    [DllImport( "msvcr70.dll", CallingConvention = CallingConvention.Cdecl )]
    public static extern int _fpreset();

    Hope this helps.

    Kind regards,

    Johan J v Rensburg
    Thursday, March 4, 2010 1:34 PM
  • Hello Johan,

    In fact, If I do not include a referecen to the .dll (and output it to the destination folder) I get a DllNotFoundException:

    "{"Unable to load DLL 'msvcr70.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

    Maybe I'm using a different system. I'm currently running Win7 x64.

    Anyway, adding the .dll to the output folder in my project make things all right. I replied just to let the people know.

    Kindly Regards,

    Igor
    Project Manager at INOVATIVA Tecnologia www.inovativatec.com
    Thursday, March 4, 2010 6:56 PM
  • For W7 OS use msvcr71.dll, really it works

    Friday, May 20, 2011 6:16 PM
  • Thanks Johan. Fixed it for me :)
    Monday, May 6, 2013 10:34 PM