Having issues on my first XAML application I have created in VB.net using Visual Studio 2010. Every time I run it and I want to click on the apply button (I am meant to input data in some fields and then click the apply button and that just shows a messagebox.show of what I have entered) the program crashes. I am running Windows 7 x64 ultimate edition. Any ideas?
The event log shows the below:
Faulting application name: CreditCard.exe, version: 1.0.0.0, time stamp: 0x4ceafa3a Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdbdf Exception code: 0xe0434352 Fault offset: 0x0000b727 Faulting process id: 0x14d0 Faulting application start time: 0x01cb8b5a4900b2cb Faulting application path: C:\Users\Chohan\Documents\Visual Studio 2010\Projects\chapter6\CreditCard\CreditCard\bin\Debug\CreditCard.exe Faulting module path: C:\Windows\syswow64\KERNELBASE.dll Report Id: 8eba45a2-f74d-11df-8e1c-506313a0ad71
Also:
Application: CreditCard.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.InvalidCastException Stack: at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String, System.Globalization.NumberFormatInfo) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String) at CreditCard.MainWindow.btnApply_Click(System.Object, System.Windows.RoutedEventArgs) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, 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) at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object) at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs) at System.Windows.Even开发者_如何学编程tRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean) at System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent) at System.Windows.UIElement.OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object) at 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, Boolean) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean) at System.Windows.Input.InputManager.ProcessStagingArea() at 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.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, 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.Run() at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at System.Windows.Application.Run(System.Windows.Window) at System.Windows.Application.Run() at CreditCard.Application.Main()
If you'd actually read the exception stack, you would find the error yourself. It's in your Apply button event handler:
System.InvalidCastException Stack: at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String, System.Globalization.NumberFormatInfo) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(System.String) at CreditCard.MainWindow.btnApply_Click(System.Object, System.Windows.RoutedEventArgs) at
The conversion from a string to a Double is not handled correctly
You are trying to cast a String
to a Double
and it's throwing an exception.
ToDouble(System.String, System.Globalization.NumberFormatInfo)
System.InvalidCastException
if you are inputing strings in the textbox and parsing it as integer or a double you'll get such error.
精彩评论