c # — переполнение или переполнение в арифметической операции wpf

Переполнение или переполнение в арифметической операции wpf

Попытка воссоздать пример virdiSDK в WPF с использованием MVVM + Prism

Сервер терминалов приступил к работе, но когда я пытаюсь закрыть приложение или получить фокус на текстовое поле для ввода, я получаю сообщение об ошибке переполнения или недостаточного значения в арифметической операции

Иногда источник: windowsbase
Несколько раз это так: PresentationFramework

стек

   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()

введите описание изображения здесь

Посмотреть код модели

Ссылка на ViewModel Кодовый файл: https://www.dropbox.com/s/4d5lz12xowshpqf/ModuleNavViewModel.cs

Код работает, но я не могу поймать ошибку.

 [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());
}

2

Решение

Благодаря ouflak и HadeS помогли мне найти проблему.

Вопрос решен.

ouflak: Сможете ли вы опубликовать код OnPropertyChanged? Я видел некоторые странные проблемы там, где существует бесконечный рекурсивный цикл, вызванный проблемами там.

вакар хабиб: да …. Когда я запускаю ucsAPI.ServerStart (255, 9870); , то OnPropertyChanged Event даже не работает, что, после запуска терминала я обновляю свой список, и он снова через ту же ошибку …
Вы правы … что я сделал после запуска терминала, я называю _fpReset (); и по крайней мере в это время не ошибка
Надеюсь, мы кое-как поймем ошибку …..
Спасибо большое, приятель …. по крайней мере, сейчас начни говорить ….;)

1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]