I have a line of code that should clear a datatable if the rowcount > 0. However despite the rowcount being 0, the clear line is executed:
I'm experiencing some very odd behaviour with this (inherited) application and have investigated whether the build is working correctly (I've cleaned and rebuilt many times, and made sure all assemblies are x86) and turned off code optimization as per this and this because I feared that my pdb files were out of sync with my code, however nothing has helped.
I'm totally stumped as to why this line of code is executing and would very much appreciate any advice.
Edit: dt is System.Data.Datatable, the exception detail is:
System.Data.RowNotInTableException occurred HResult=-2146232024 Message=This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row. Source=System.Data StackTrace: at System.Data.DataRow.GetDefaultRecord() InnerException: