2011-04-13 21 views
1
System.InvalidCastException was unhandled 
    Message=Unable to cast object of type 'SportSoft.SSBLL.CMembershipTypeAdvanceBooking' to type 'SportSoft.SSBLL.CAreaActivities'. 
    Source=SSDlgs 
    StackTrace: 
     at SportSoft.SSDlgs.frmAdvanced.ListChanged(Object sender, ListChangedEventArgs e) in C:\Documents and Settings\a_rahnema\My Documents\Visual Studio 2010\Projects\SSDlgs\Booking\frmAdvanced.vb:line 56 
     at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e) 
     at SportSoft.SSBLL.CBOView.OnListChanged(ListChangedEventArgs e) in C:\Documents and Settings\a_rahnema\My Documents\Visual Studio 2010\Projects\SSBLL\BOView.vb:line 200 
     at SportSoft.SSBLL.CBOView.AddNew() in C:\Documents and Settings\a_rahnema\My Documents\Visual Studio 2010\Projects\SSBLL\BOView.vb:line 680 
     at System.Windows.Forms.CurrencyManager.AddNew() 
     at System.Windows.Forms.DataGrid.AddNewRow() 
     at System.Windows.Forms.DataGridAddNewRow.OnEdit() 
     at System.Windows.Forms.DataGrid.Edit(String displayText) 
     at System.Windows.Forms.DataGrid.OnEnter(EventArgs e) 
     at System.Windows.Forms.Control.NotifyEnter() 
     at System.Windows.Forms.ContainerControl.UpdateFocusedControl() 
     at System.Windows.Forms.ContainerControl.AssignActiveControlInternal(Control value) 
     at System.Windows.Forms.ContainerControl.ActivateControlInternal(Control control, Boolean originator) 
     at System.Windows.Forms.ContainerControl.ActivateControlInternal(Control control) 
     at System.Windows.Forms.Control.WmSetFocus(Message& m) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.SetFocus(HandleRef hWnd) 
     at System.Windows.Forms.Control.FocusInternal() 
     at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.Run(Form mainForm) 
     at SportSoft.ssBOffice.frmMain.Main() in C:\Documents and Settings\a_rahnema\My Documents\Visual Studio 2010\Projects\ssBOffice\Forms\frmMain.vb: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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: 
+0

「無法投射'SportSoft.SSBLL.CMembershipTypeAdvanceBooking'類型的對象來鍵入'SportSoft.SSBLL.CAreaActivities'。」什麼是CMembershipTypeAdvanceBooking和CAreaActivities類型? – sukru 2011-04-13 16:21:58

+0

NOOOOOO! MFC風格的命名!野獸還沒死! – 2011-04-13 16:25:13

回答

1

在你frmAdvanced類,你有一個ListChangedEventHandler。在此方法中的某處,您正試圖將SportSoft.SSBLL.CMembershipTypeAdvanceBooking轉換成SportSoft.SSBLL.CAreaActivities。這是不允許的。

+0

好!!!!!!!我讓它消失了,發現了問題!乾杯 – 2011-04-14 09:26:12

1

看起來像它說,它無法投型「SportSoft.SSBLL.CMembershipTypeAdvanceBooking」的對象上鍵入frmAdvanced.vb的56行:)

1

「SportSoft.SSBLL.CAreaActivities」在文件在56行上的frmAdvanced.vb,您正在將類型爲CAreaActivities的變量設置爲類型爲CMembershipTypeAdvanceBooking的值。

由於CMembershipTypeAdvanceBooking未從CAreaActivities繼承,因此分配在運行時失敗。

如果您想更多的幫助,你應該張貼的部分frmAdvanced.vb的,其中包括56行

0

其說法文:

無法轉換 型「SportSoft的對象。 SSBLL.CMembershipTypeAdvanceBooking' to type 'SportSoft.SSBLL.CAreaActivities'。

某處有是試圖使一個CMembershipTypeAdvanceBooking對象爲CAreaActivities目標代碼,它是不允許的。