Cannot serialize the DataTable. DataTable name is not set

I’m running into this error

UIPath ie crashes

when I’m trying to do this:

"C:\Users\admin\Documents\UiPath\Level3AcmeTest\L3A2\" + row.Item("TaxID").ToString

In a loop that also uses the row.Item("") selection methodology. In fact, I’ve used it several times.

Looking up the error, I find an SO Q&A that isn’t helpful https://stackoverflow.com/questions/38322181/why-cannot-serialize-the-datatable-datatable-name-is-not-set and a random blog post http://www.niteshluharuka.com/cannot-serialize-the-datatable-datatable-name-is-not-set-solution/ that seems helpful, but I can’t make it work in UIpath.

I don’t see a name property:

no name property

What’s going on? How do I fix this?

Can you share your workflow?

@Robot.Builder.9001
If you read the Stack Overflow link you posted above, you can see that the property is TableName, not Name. Try assigning a value to the TableName before your operation.

OK, I see the actual property, and when I use it… I get a different error. Looking at some pages, I think this is starting to look like a red herring. Accessing the datatable was working just fine until I added in the IE code. Not sure how that’s related though.

19.10.4+Branch.support-v2019.10.Sha.fe819a658cad0585a64d2f8af94fad5c30b8d122

Message: Type 'System.Collections.IEnumerable' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.

datatable contract

Exception Type: System.Runtime.Serialization.InvalidDataContractException

RemoteException wrapping System.Runtime.Serialization.InvalidDataContractException: Type 'System.Collections.IEnumerable' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types. 
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.Activities.WorkflowApplication.IdleEventHandler.OnStage2Complete(IAsyncResult lastResult, WorkflowApplication instance, Boolean isStillSync)
   at System.Activities.WorkflowApplication.EventFrame(IAsyncResult result)

As far as my code…

From what I can tell, this is the activity that fails. I’m trying to set the save to path, and it seems to choke on the operation prior to converting it to a string.

"C:\Users\admin\Documents\UiPath\Level3AcmeTest\L3A2\" + row.Item("TaxID").ToString

Well, it was the activity. I put a log message before it to see if the set text activity was what was failing, but it seems that the string concatenation is causing the error.

Which makes no sense, because I am using the exact same way to pull the Tax ID in an earlier chunk of the code to write it to the CSV file.

I think the problem was that I had commented out some code, expecting it to not be executed. I moved it out of the flow, and all of a sudden there was no more red herring error. That tells me that commented out code isn’t really commented out. I’ve seen this in some languages where most people expect the commented out code to not run, but there’s some kind of middleground where it’s still evaluated or something.

I did get a different error, but that’s how things roll. On to the next error! At least it’s not a crash.