Hello,
I have made some tests to understand why my Dataset didn't work and I have seen the problem :
When you fill a dataset with a DataAdapter, the string columns have the property MaxLength set.
You must clear all the values of MaxLength (set to -1) and you can export to binary format
So you must do the following code
private void ClearMaxLength (DataSet ATst)
{
foreach (DataTable dtbTmp in ATst.Tables)
{
foreach (DataColumn CurCol in dtbTmp.Columns)
if (CurCol.MaxLength > 0)
CurCol.MaxLength = -1;
}
}
And after that you can serialize (in my case in a zip directly)
ds.RemotingFormat = SerializationFormat.Binary;
IFormatter myFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try
{
Stream myStreamFina = new FileStream(FileName, FileMode.Create, FileAccess.Write);
var ZipStream = new GZipStream(myStreamFina, CompressionMode.Compress, false);
myFormatter.Serialize(ZipStream, ds);
ZipStream.Flush();
myStreamFina.Flush();
ZipStream.Close();
myStreamFina.Close();
I don't understand why there is a problem in Core5 and not in NET4.6
Thanks again for the help.