I am getting this error when I publish my code to the server (GoDaddy), but locally when I run in code
Unable to cast object of type
'System.Data.EnumerableRowCollection`1[System.Data.DataRow]' to type
'System.Data.EnumerableRowCollection`1[System.Data.DataRow]'
The code that the error is triggering on is:
foreach (DataRow dr in ds.Tables[0].Rows)
{
error occuring here ==> var images = (from DataRow myRow in ds.Tables[1].AsEnumerable()
where (int)myRow["ProductID"] == Convert.ToInt32(dr["ProductID"])
select myRow);
Product product = new Product(dr, images);
productCollection.Add(product);
}
I don’t understand how it cannot cast one type to the same type and why it would only happen on the web server. The domain is set up on the 3.5 framework, other linq queries execute successfully, so I am at a loss.
Any suggestions?
Are you about the line that causes the error?
I would expect it here:
But the fact that it does not happen on your dev system but only after deployment suggests that an assembly is out of sync. Rebuild at the server and/or make sure you push out all assemblies.