SerializeToStream function


Author
Message
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
Using this code:

MemoryStream myStream = new MemoryStream();

boAllUsers1.NewRow();

boAllUsers1.SerializeToStream(myStream);

myStream.Position = 0;

BOLibrary.boAllUsers allUsers = (BOLibrary.boAllUsers)BusinessLayer.DeserializeBusinessObject(myStream);



1) {"Type 'BOLibrary.boAllUsers' in Assembly 'BOLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable."}



Is this something that we are supposed to have to address manually for each BO or should the code generator mark them all as [Serializable]?



2) The SerializeToStream method should set the Position to 0 before returning. Otherwise you get an "End of Stream reached unexpectedly" exception on the DeserializeBusinessObject call.



3) After addressing 1 and 2 the following exception is thrown:

{"The constructor to deserialize an object of type 'BOLibrary.boAllUsers' was not found."}



Reply
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
Thank you. Everything seems to be working as you described.



I have a residual problem with this little sample that I am working on:



The table schema looks like this:

new DataColumn("ID", typeof(System.String)),





In my code:

boAllUsers1.NewRow();

boAllUsers1.ID = "FRED";



throws the following exception:

{"Input string was not in a correct format.Couldn't store in ID Column. Expected type is Int32."}



and if you use the visualizer to look at the underlying DataTable, it shows a -1 in the ID column.



All of the generated code seems to know that this column is a string column but the datatable thinks it's an int.



This has me stumped.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search