..Row cannot be cast to ..Row when appear to be same. InvalidCastException

rowTS = CType(TimeSheetBindingSource.Current, DataRowView.Row, dsMyCo.TimeSheetRow

A first chance exception of type ‘System.InvalidCastException’ occurred in MyCompany.exe

[A]TimeSheetRow cannot be cast to [B]TimeSheetRow. Type A originates from ‘ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ in the context ‘Default’ at location ‘Project…\bin\Debug\ProjectName.exe’. Type B originates from ‘ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ in the context ‘Default’ at location Project…\bin\Debug\ProjectName.exe’.

Check you are converting from Rows in the same dataset. So if a table appears in more than one dataset check you are using the correct one.

Leave a comment