2010-11-23 75 views
0

在使用Visual Studio 2010在VB.net中創建我的第一個XAML應用程序時出現問題。每次運行它時,我想單擊應用按鈕(我的意思是在某些字段中輸入數據,然後點擊應用按鈕,它只顯示我輸入的messagebox.show)程序崩潰。我正在運行Windows 7 x64終極版。有任何想法嗎?程序意外關閉

事件日誌顯示以下:

錯誤應用程序名稱:CreditCard.exe,版本:1.0.0.0,時間戳:0x4ceafa3a 錯誤模塊名稱:KERNELBASE.dll,版本:6.1.7600.16385,時間戳:0x4a5bdbdf 異常代碼:0xe0434352 故障偏移:0x0000b727 出錯進程ID:0x14d0 錯誤應用程序開始時間:0x01cb8b5a4900b2cb 錯誤的應用程序路徑:C:\用戶\ Chohan \文件\的Visual Studio 2010 \項目\第六章\信用卡式\信用卡式\ bin \ Debug \ CreditCard.exe 錯誤模塊路徑:C:\ Windows \ syswow64 \ KERNELBASE.dll 報告編號:8eba45a2-f74d-11df-8e1c-506313a0ad71


另外:

應用:CreditCard.exe Framework版本:v4.0.30319 說明:該工藝由於終止未處理的異常。 異常的信息:System.InvalidCastException 堆棧: 在Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String,System.Globalization.NumberFormatInfo) 在Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String) 在CreditCard.MainWindow.btnApply_Click(System.Object的,System.Windows.RoutedEventArgs) 在System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object的,System.Windows.RoutedEventArgs) 在System.Windows.EventRoute.InvokeHandlersImpl(System.Object的, System.Windows.RoutedEventArgs,布爾) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject,System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEvent ()) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input。 MouseButtonEventArgs) 在System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object的,System.Windows.Input.MouseButtonEventArgs) 在System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate,System.Object的) 在System.Windows。 RoutedEventArgs.InvokeHandler(System.Delegate,System.Object) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object,System.Windows.RoutedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(System.Object,System.Windows。 RoutedEventArgs,布爾值) System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject,System.Windows.RoutedEventArgs,System.Windows.RoutedEvent) at System.Windows.UIElement.OnMouseUpThunk(System.Object,System.Windows.Input.MouseButtonEventArgs) 在System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate,System.Object的) 在System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate,System.Object的) 在System.Windows.RoutedEventHandlerInfo.InvokeHandler(系統。對象,System.Windows.RoutedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(System.Object,System.Windows.RoutedEventArgs,Boolean) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject,System.Windows。RoutedEventArgs) 在System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs) 在System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs,布爾值) 在System.Windows.Input.InputManager.ProcessStagingArea() System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs) at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput (IntPtr,System.Windows.Input.InputMode,Int32,System.Windows.Input.RawMouseActions,Int32,Int32,Int32) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr,MS.Internal.Interop.WindowMessage,IntPtr ,IntPtr,Boolean ByRef) at System.Windows.Interop.HwndSo在MS.Win32.HwndWrapper.WndProc(IntPtr,Int32,IntPtr,IntPtr,布爾ByRef) 在MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)上urce.InputFilterMessage(IntPtr,Int32,IntPtr,IntPtr,布爾ByRef) 在System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,System.Object,Int32) 在MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object,System.Delegate,System.Object,Int32,System。代理) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority,System.TimeSpan,System.Delegate,System.Object,Int32) IntPtr,IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher。在System.Windows.Application.RunDispatcher(System.Object)上運行() System.Windows.Application.RunInternal(System.Windows.Window) System.Windows.Application.Run(System.Windows.Window) 在System.Windows.Application.Run() at CreditCard.Application.Main()

回答

0

如果你真的讀過異常堆棧,你會發現自己的錯誤。它在你的應用按鈕事件處理程序:

System.InvalidCastException堆棧:在Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String,System.Globalization.NumberFormatInfo)在Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(系統.String)在CreditCard.MainWindow.btnApply_Click(System.Object的,System.Windows.RoutedEventArgs)

從字符串到雙精度的轉換未正確處理

0

您試圖將String投給Double,它會拋出異常。

ToDouble(System.String, System.Globalization.NumberFormatInfo)

+0

是的 - 它出 - 該死錯字在我的編碼的一部分!去了一百萬次,然後一步一步地看着它,終於實現了!感謝您的幫助 - 您幫助縮小了我應該尋找的位置。 – lara400 2010-11-23 22:22:12

0

System.InvalidCastException

如果你輸入查詢的文本字符串和解析它爲整數或雙你會得到這樣的錯誤。

+0

如果`TextBox`中的`string`全部爲數字,則不會。 – Gabe 2010-11-23 22:29:06

+0

+1(不是因爲答案很好,但是),因爲-1在這裏似乎有點苛刻 - 我個人認爲阿里必須說的話很清楚,肯定不值得-1。 – Sheridan 2011-09-08 16:33:03