算术运算中的溢出或下溢wpf
尝试使用MVVM + Prism在WPF中重新创建virdiSDK示例
终端服务器入门,但是当我尝试关闭应用程序或尝试关注文本框以进行输入时,我在算术运算中出现错误溢出或下溢
有时候来源是: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());
}
答案 0 :(得分:1)
感谢ouflak和HadeS帮助我找到问题。
问题已经解决了。
ouflak:你能发布OnPropertyChanged代码吗?我在那里看到了一些奇怪的问题,那里存在因问题引起的无限递归循环。
waqar habib:是的....当我启动ucsAPI.ServerStart(255,9870); ,然后OnPropertyChanged事件甚至没有工作什么,启动终端后我更新我的列表,它再次通过相同的错误... 你是对的......我在启动终端后做了什么我调用_fpReset();至少在这个时候没有通过错误 我希望我们有些抓住错误..... 非常感谢伙计....至少它现在开始说话....;)