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:
回答
在你frmAdvanced
類,你有一個ListChangedEventHandler
。在此方法中的某處,您正試圖將SportSoft.SSBLL.CMembershipTypeAdvanceBooking
轉換成SportSoft.SSBLL.CAreaActivities
。這是不允許的。
好!!!!!!!我讓它消失了,發現了問題!乾杯 – 2011-04-14 09:26:12
錯誤是說被轉換的對象不能轉換爲指定的類型。
請參見:http://msdn.microsoft.com/en-us/library/system.invalidcastexception.aspx
看起來像它說,它無法投型「SportSoft.SSBLL.CMembershipTypeAdvanceBooking」的對象上鍵入frmAdvanced.vb的56行:)
「SportSoft.SSBLL.CAreaActivities」在文件在56行上的frmAdvanced.vb,您正在將類型爲CAreaActivities
的變量設置爲類型爲CMembershipTypeAdvanceBooking
的值。
由於CMembershipTypeAdvanceBooking
未從CAreaActivities
繼承,因此分配在運行時失敗。
如果您想更多的幫助,你應該張貼的部分frmAdvanced.vb的,其中包括56行
其說法文:
無法轉換 型「SportSoft的對象。 SSBLL.CMembershipTypeAdvanceBooking' to type 'SportSoft.SSBLL.CAreaActivities'。
某處有是試圖使一個CMembershipTypeAdvanceBooking
對象爲CAreaActivities
目標代碼,它是不允許的。
- 1. 這個例外是什麼意思?
- 2. 這些例外是什麼意思?
- 3. 這是什麼奇怪的代碼符號的意思
- 4. 奇怪的aptana亮點。他們的意思是什麼?
- 5. 是什麼意思:是什麼意思?
- 6. 這些奇怪的問號是什麼意思?
- 7. C++中的奇怪表達式 - 這是什麼意思?
- 8. Intellij上這個奇怪的圖標是什麼意思?
- 9. CoffeeScript - 這個奇怪的「返回」事件是什麼意思?
- 10. 奇怪的清漆503錯誤 - 這是什麼意思?
- 11. 奇怪的結構,這是什麼意思?
- 12. 奇怪的JavaScript語句,這是什麼意思?
- 13. 這些奇怪的字符是什麼意思?
- 14. 這個奇怪的C++定義是什麼意思?
- 15. Apache日誌顯示奇怪的^ @字符?這是什麼意思 ?
- 16. git checkout:這個奇怪的輸出是什麼意思?
- 17. 這個奇怪的澤西警告是什麼意思?
- 18. 這個奇怪的語法是什麼意思
- 19. 奇怪的性能數據實例Volume1#1 - 這是什麼意思?
- 20. 代碼的意思是什麼意思出於好奇
- 21. Haskell中的實例是什麼意思?
- 22. 這是什麼意思,它的輸出?
- 23. 。奇怪的例外
- 24. 奇怪的例外
- 25. 奇怪的例外
- 26. 奇怪的例外
- 27. 奇怪的例外
- 28. 這個例外非法的爭論是什麼意思?
- 29. 什麼是string array [] =「」;是什麼意思?爲什麼它有效?
- 30. 實例化特徵是什麼意思?
「無法投射'SportSoft.SSBLL.CMembershipTypeAdvanceBooking'類型的對象來鍵入'SportSoft.SSBLL.CAreaActivities'。」什麼是CMembershipTypeAdvanceBooking和CAreaActivities類型? – sukru 2011-04-13 16:21:58
NOOOOOO! MFC風格的命名!野獸還沒死! – 2011-04-13 16:25:13