【发布时间】:2014-05-02 14:22:30
【问题描述】:
我是 C# 新手。我得到了这个例外 在我的程序结束时:
An unhandled exception of type 'System.ArithmeticException' occurred in mscorlib.dll
Additional information: Overflow or underflow in the arithmetic operation.
If there is a handler for this exception, the program may be safely continued.
引发此异常的行似乎与任何算术无关 操作 - 实际上我认为这是我的程序的最后一行,例如,当它试图存在时。
我真的不知道出了什么问题。有没有办法解决这个问题?
ps。调用栈:
> mscorlib.dll!double.IsPositiveInfinity(double d) + 0xc bytes
PresentationFramework.dll!System.Windows.Window.ValidateTopLeft(double length) + 0x25 bytes
PresentationFramework.dll!System.Windows.Window.CoerceTop(System.Windows.DependencyObject d, object value) + 0x64 bytes
WindowsBase.dll!System.Windows.DependencyObject.ProcessCoerceValue(System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, ref System.Windows.EntryIndex entryIndex, ref int targetIndex, ref System.Windows.EffectiveValueEntry newEntry, ref System.Windows.EffectiveValueEntry oldEntry, ref object oldValue, object baseValue, object controlValue, System.Windows.CoerceValueCallback coerceValueCallback, bool coerceWithDeferredReference, bool coerceWithCurrentValue, bool skipBaseValueChecks) + 0x55 bytes
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) + 0x247 bytes
WindowsBase.dll!System.Windows.DependencyObject.CoerceValue(System.Windows.DependencyProperty dp) + 0xd5 bytes
PresentationFramework.dll!System.Windows.Window.SetupInitialState(double requestedTop, double requestedLeft, double requestedWidth, double requestedHeight) + 0x135 bytes
PresentationFramework.dll!System.Windows.Window.CreateSourceWindow(bool duringShow) + 0x30b bytes
PresentationFramework.dll!System.Windows.Window.CreateSourceWindowDuringShow() + 0xa bytes
PresentationFramework.dll!System.Windows.Window.SafeCreateWindowDuringShow() + 0x3f bytes
PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox) + 0x77 bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x56 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x3a bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() + 0xac bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) + 0x38 bytes
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x41 bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0x5b bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() + 0x16b bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x5a bytes
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x9b bytes
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x6b bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x56 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x3a bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0x10e bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0xf1 bytes
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) + 0xae bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) + 0x49 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() + 0x4b bytes
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) + 0x17 bytes
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) + 0x6f bytes
PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) + 0x26 bytes
PresentationFramework.dll!System.Windows.Application.Run() + 0x1b bytes
CardReaderGui.exe!CardReaderGui.App.Main() + 0x59 bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6b bytes
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x27 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x6f bytes
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x41 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
[Native to Managed Transition]
【问题讨论】:
-
发布您的代码,否则我们将无法提供帮助。
-
@Bobson:我明白了,但这就是问题所在,项目很大,当然我不能在这里发布整个项目,而且我不知道代码的哪一部分可能出错了:/
-
可以设置VS在异常发生时中断。 Debug -> Exceptions,然后选择 Common Language Runtime Exceptions -> System -> System.ArithmeticException 下的一项。然后,您可以在堆栈跟踪中断时发布堆栈跟踪和与堆栈跟踪相关的代码。
-
@Josh:请查看我的堆栈跟踪问题(如果我正确复制了它)。另外我怎样才能找到与堆栈跟踪相关的代码???
-
你在使用 WPF 吗?看起来与此相关:stackoverflow.com/questions/2407040/…
标签: c#