DataTable() Fix in Mono 4.0

If you recently upgraded to Mono 4.0 and you use DataTables to return SQL results (in my case from Postgresql), you may have received a heart attack similar to mine when you were bombarded with the error:

SourceTable is required to be a non-empty string

This appears to be related to Bug #29557: https://bugzilla.xamarin.com/show_bug.cgi?id=29557

Thought .Net is perfectly happy allow

DataTable whatever = new DataTable();

Mono will throw an exception.
It is looking for you to name the data table.

To fix, simply change

DataTable whatever = new DataTable();

to

DataTable whatever = new DataTable("some_name");

Happy compiling!

2 thoughts on “DataTable() Fix in Mono 4.0”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.