2

Overflow or underflow in the arithmetic operation wpf

Trying to reCreate virdiSDK Sample in WPF using MVVM + Prism

Terminal Server Get Started, but when I try to close the application or try to get focus on textbox for entry I got error Overflow or underflow in the arithmetic operation

Some times the source is : windowsbase some times it is : PresentationFramework

Stack

   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, Double opacity, 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, Boolean isSelectionActive, 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.RaiseTrustedEvent(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, Boolean forceToNullIfFailed)
   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.RaiseTrustedEvent(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, WindowMessage 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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   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 ATSApp.App.Main() in e:\Working Projects\ATS\ATS\Shell\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

enter image description here

View Model Code

Link to ViewModel Code File: https://www.dropbox.com/s/4d5lz12xowshpqf/ModuleNavViewModel.cs

The code Run, but I am unable to catch the Error.

 [Export(typeof(IModuleNavViewModel))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class ModuleNavViewModel : ViewModelBase, IModuleNavViewModel
    {
        private IRegionManager _regionManager;
        IEventAggregator _eventAggregator;
        private FPTerminalActions _CurrentAction;
        public FPTerminalActions CurrentAction
        {
            get { return _CurrentAction; }
            set { _CurrentAction = value; OnPropertyChanged("CurrentAction"); }
        }

        [ImportingConstructor]
        public ModuleNavViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
            : base(regionManager, eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _regionManager = regionManager;
            Categories = LoadTreeViewCategories();

            LstMessage = new List<string>();
            Message5 = "0";
            Message2 = "0";
            Message1 = "0";
            CurrentAction = new FPTerminalActions();
            RegisterCommands();
        }
        public override void RegisterCommands()
        {
            GlobalCommands.StartCommand.RegisterCommand(StartCommand);
            GlobalCommands.StopCommand.RegisterCommand(StopCommand);
        }
        private object DllImport(string p)
        {
            throw new NotImplementedException();
        }
        public override bool CanStart()
        {
            return true;
        }
        public override bool CanStop()
        {
            return true;
        }
        private bool IsServerRunning = false;
        [DllImport("msvcr71.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern int _fpreset();
        public override void Start()
        {
            _fpreset();
            if (!IsServerRunning)
            {
                IntializeDevice();
                IsServerRunning = true;
            }
            ucsAPI.ServerStart(255, 9870);
            LstMessage.Clear();
        }
        public override void Stop()
        {
            ucsAPI = null;
            ucBioBSP = null;
            LstMessage.Clear();
        }

        private void IntializeDevice()
        {
            // create UCSAPI Instance
            ucsAPI = new UCSAPIClass();
            serveruserData = ucsAPI.ServerUserData as IServerUserData;
            terminalUserData = ucsAPI.TerminalUserData as ITerminalUserData;
            accessLogData = ucsAPI.AccessLogData as IAccessLogData;
            serverAuthentication = ucsAPI.ServerAuthentication as IServerAuthentication;

            // create UCBioBSP Instance
            ucBioBSP = new UCBioBSPClass();
            fpData = ucBioBSP.FPData as IFPData;
            device = this.ucBioBSP.Device as IDevice;
            extraction = this.ucBioBSP.Extraction as IExtraction;

            //terminalID = txtTerminalID.Text;

            // create event handle
            ucsAPI.EventTerminalConnected += new _DIUCSAPIEvents_EventTerminalConnectedEventHandler(UCSCOMObj_EventTerminalConnected);
            ucsAPI.EventTerminalDisconnected += new _DIUCSAPIEvents_EventTerminalDisconnectedEventHandler(UCSCOMObj_EventTerminalDisconnected);
            ucsAPI.EventAddUser += new _DIUCSAPIEvents_EventAddUserEventHandler(ucsAPI_EventAddUser);
            ucsAPI.EventAntipassback += new _DIUCSAPIEvents_EventAntipassbackEventHandler(ucsAPI_EventAntipassback);
            ucsAPI.EventAuthTypeWithUniqueID += new _DIUCSAPIEvents_EventAuthTypeWithUniqueIDEventHandler(ucsAPI_EventAuthTypeWithUniqueID);
            ucsAPI.EventAuthTypeWithUserID += new _DIUCSAPIEvents_EventAuthTypeWithUserIDEventHandler(ucsAPI_EventAuthTypeWithUserID);
            ucsAPI.EventControlPeripheralDevice += new _DIUCSAPIEvents_EventControlPeripheralDeviceEventHandler(ucsAPI_EventControlPeripheralDevice);
            ucsAPI.EventDeleteAllUser += new _DIUCSAPIEvents_EventDeleteAllUserEventHandler(ucsAPI_EventDeleteAllUser);
            ucsAPI.EventDeleteUser += new _DIUCSAPIEvents_EventDeleteUserEventHandler(ucsAPI_EventDeleteUser);
            ucsAPI.EventFingerImageData += new _DIUCSAPIEvents_EventFingerImageDataEventHandler(ucsAPI_EventFingerImageData);
            ucsAPI.EventFirmwareUpgraded += new _DIUCSAPIEvents_EventFirmwareUpgradedEventHandler(ucsAPI_EventFirmwareUpgraded);
            ucsAPI.EventFirmwareUpgrading += new _DIUCSAPIEvents_EventFirmwareUpgradingEventHandler(ucsAPI_EventFirmwareUpgrading);
            ucsAPI.EventFirmwareVersion += new _DIUCSAPIEvents_EventFirmwareVersionEventHandler(ucsAPI_EventFirmwareVersion);
            ucsAPI.EventGetAccessLog += new _DIUCSAPIEvents_EventGetAccessLogEventHandler(ucsAPI_EventGetAccessLog);
            ucsAPI.EventGetAccessLogCount += new _DIUCSAPIEvents_EventGetAccessLogCountEventHandler(ucsAPI_EventGetAccessLogCount);
            ucsAPI.EventGetTAFunction += new _DIUCSAPIEvents_EventGetTAFunctionEventHandler(ucsAPI_EventGetTAFunction);
            ucsAPI.EventGetUserCount += new _DIUCSAPIEvents_EventGetUserCountEventHandler(ucsAPI_EventGetUserCount);
            ucsAPI.EventGetUserData += new _DIUCSAPIEvents_EventGetUserDataEventHandler(ucsAPI_EventGetUserData);
            ucsAPI.EventGetUserInfoList += new _DIUCSAPIEvents_EventGetUserInfoListEventHandler(ucsAPI_EventGetUserInfoList);
            ucsAPI.EventOpenDoor += new _DIUCSAPIEvents_EventOpenDoorEventHandler(ucsAPI_EventOpenDoor);
            ucsAPI.EventPictureLog += new _DIUCSAPIEvents_EventPictureLogEventHandler(ucsAPI_EventPictureLog);
            ucsAPI.EventRealTimeAccessLog += new _DIUCSAPIEvents_EventRealTimeAccessLogEventHandler(ucsAPI_EventRealTimeAccessLog);
            ucsAPI.EventSetAccessControlData += new _DIUCSAPIEvents_EventSetAccessControlDataEventHandler(ucsAPI_EventSetAccessControlData);
            ucsAPI.EventSetTAFunction += new _DIUCSAPIEvents_EventSetTAFunctionEventHandler(ucsAPI_EventSetTAFunction);
            ucsAPI.EventSetTATime += new _DIUCSAPIEvents_EventSetTATimeEventHandler(ucsAPI_EventSetTATime);
            ucsAPI.EventTerminalStatus += new _DIUCSAPIEvents_EventTerminalStatusEventHandler(ucsAPI_EventTerminalStatus);
            ucsAPI.EventVerifyCard += new _DIUCSAPIEvents_EventVerifyCardEventHandler(ucsAPI_EventVerifyCard);
            ucsAPI.EventVerifyFinger1to1 += new _DIUCSAPIEvents_EventVerifyFinger1to1EventHandler(ucsAPI_EventVerifyFinger1to1);
            ucsAPI.EventVerifyFinger1toN += new _DIUCSAPIEvents_EventVerifyFinger1toNEventHandler(ucsAPI_EventVerifyFinger1toN);
            ucsAPI.EventVerifyPassword += new _DIUCSAPIEvents_EventVerifyPasswordEventHandler(ucsAPI_EventVerifyPassword);
            ucsAPI.EventPrivateMessage += new _DIUCSAPIEvents_EventPrivateMessageEventHandler(ucsAPI_EventPrivateMessage);
            ucsAPI.EventPublicMessage += new _DIUCSAPIEvents_EventPublicMessageEventHandler(ucsAPI_EventPublicMessage);
            ucsAPI.EventUserFileUpgrading += new _DIUCSAPIEvents_EventUserFileUpgradingEventHandler(ucsAPI_EventUserFileUpgrading);
            ucsAPI.EventUserFileUpgraded += new _DIUCSAPIEvents_EventUserFileUpgradedEventHandler(ucsAPI_EventUserFileUpgraded);

            ucBioBSP.OnCaptureEvent += new _IUCBioBSPEvents_OnCaptureEventEventHandler(ucBioBSP_OnCaptureEvent);
            ucBioBSP.OnEnrollEvent += new _IUCBioBSPEvents_OnEnrollEventEventHandler(ucBioBSP_OnEnrollEvent);

            //InitListview();
            //InitCommandList();

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
        }
        void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            //MessageBox.Show(e.Exception.ToString());
        }
MD XF
  • 7,860
  • 7
  • 40
  • 71
waqar habib
  • 315
  • 1
  • 3
  • 17
  • Sorry It is basically calling C++ Dll/Library thats why Tag C++ @HadeS – waqar habib Mar 05 '14 at 05:14
  • can you add the code which is causing this error...from error message it will not be clear to anyone... – HadeS Mar 05 '14 at 05:16
  • @HadeS the Code Run, I can start the server (Terminal Server) using its dll function. but when I try to click on other button or textarea its break. – waqar habib Mar 05 '14 at 06:09
  • I am not C# expert ... found this [question](http://stackoverflow.com/questions/2407040/overflow-or-underflow-in-the-arithmetic-operation-wpf-specific-issue) might help you... :-) – HadeS Mar 05 '14 at 06:38
  • Yes the problem is similar to that I already tried that but unable to fix the issue. – waqar habib Mar 05 '14 at 06:41
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/49019/discussion-between-hades-and-waqar-habib) – HadeS Mar 05 '14 at 06:59
  • I am in Chat Room @HadeS – waqar habib Mar 05 '14 at 07:39

1 Answers1

1

Thanks to ouflak and HadeS helping me finding the problem.

The issue been solved out.

ouflak: Would you be able to post the OnPropertyChanged code? I've seen some strange issues there where there is an infinite recursive loop caused by issues there.

waqar habib: yep.... When I start ucsAPI.ServerStart(255, 9870); , then OnPropertyChanged Event even not working what , after starting the terminal I update my list and it again through the same error... you are right... what I did after starting the terminal I call the _fpReset(); and at least at this time not through the error I hope we some how grab the error..... Thank you so much buddy.... at least it start talking now.... ;)

waqar habib
  • 315
  • 1
  • 3
  • 17