0

Ok, I'm trying to serialize a data table in vb.net:

Dim dt As New System.Data.DataTable

and for the serializer:

Dim js As JavaScriptSerializer = New JavaScriptSerializer()
dim jsonString as string
jsonString=js.serialize(dt)

when it serialize the data table on the last line, it got an error:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Web.Extensions.dll

Additional information: A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo'

I even make the simplest datatable with only 1 column and 1 row, but it just won't serialize it,

I know that this kind of question was answered: in here

but I don't know how to implement the answer (make a new class), or maybe there's an even better solution?

Community
  • 1
  • 1
Eldon Lesley
  • 915
  • 6
  • 19
  • 38

1 Answers1

1

As far as I know there is not out of the box serializer for DataTable objects. I ended up going with a full custom serialization. Another approach could be converting first your DataTable to an IEnumerable<> and then, serializing.

However, this link may be helpful: JSV

coffekid
  • 621
  • 2
  • 10
  • 25