Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.InvalidCastException: System.Data.DataViewManagerListItemTypeDescriptor
    text
    copied!<p>Am getting an exception randomly. I have a barcode scanner which enters barcodes into a table. The code is written in C#. I was able to get the exception twice at first; however, am no longer able to generate it. The exception is System.InvalidCastException: Unable to cast object of type 'System.Data.DataViewManagerListItemTypeDescriptor' to type 'System.Data.DataRowView'. I generated it at first by scanning 2 different water bottles, 2-3 times each. Then when I hit the save button, I got the exception. I tried Google for researching if someone else has got this error before, but could not find anyone with similar issue in same context. The exception is thrown in the following code segment:</p> <pre> foreach (object o in this.theBindingSource.List) { System.Data.DataRowView dataRowView1 = (System.Data.DataRowView)o; } </pre> <p>Apparently, sometimes, o is of type System.Data.DataViewManagerListItemTypeDescriptor and not of type System.Data.DataRowView. Any ideas why this exception is thrown?</p> <p>The BindingSource is being populated by the database:</p> <pre> XYZDataAccess.TypedDataSets.ABCTag tags = XYZDataAccess.DAL.ABCTagDAL.GetABCTags( DeliverySession.DeliverySessionId); if (tags != null && tags.Tables[0] != null) { theBindingSource.Sort = ""; theBindingSource.DataSource = tags; } </pre> <p>The reason I had to loop through the binding source is that another DataGridView needs to be populated with the contents of the bindindg source; furthermore, the DataGridView implemented a custom sorting for the data in the control or view. In addition to removing the direct access of the List should I specify the DisplayMember property?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload