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 :(得分:1)
在frmAdvanced
课程中,您有一个ListChangedEventHandler
。在此方法的某个位置,您尝试将SportSoft.SSBLL.CMembershipTypeAdvanceBooking
转换为SportSoft.SSBLL.CAreaActivities
类型。这是不允许的。
答案 1 :(得分:1)
看起来它说它无法投射'SportSoft.SSBLL.CMembershipTypeAdvanceBooking'类型的对象在frmAdvanced.vb的第56行输入'SportSoft.SSBLL.CAreaActivities':)
答案 2 :(得分:1)
在第56行的文件frmAdvanced.vb中,您要将CAreaActivities
类型的变量设置为CMembershipTypeAdvanceBooking
类型的值。
由于CMembershipTypeAdvanceBooking
未从CAreaActivities
继承,因此分配在运行时失败。
如果您需要其他帮助,请发布包含第56行的frmAdvanced.vb文本的一部分。
答案 3 :(得分:0)
错误是说正在投射的对象无法转换为指定的类型。
请参阅:http://msdn.microsoft.com/en-us/library/system.invalidcastexception.aspx
答案 4 :(得分:0)
它的说法:
无法投射类型的对象 'SportSoft.SSBLL.CMembershipTypeAdvanceBooking' 输入 'SportSoft.SSBLL.CAreaActivities'。
某处有些代码试图将CMembershipTypeAdvanceBooking
对象转换为CAreaActivities
对象并且不允许这样做。