Please tell me why this:
static void Main(string[] args) {
Bid bid1 = new Bid(23,10.0F,3,0,DateTime.Now);
BinaryFormatter formatter = new BinaryFormatter();
Stream depot = new MemoryStream();
formatter.Serialize(depot, bid1);
Console.WriteLine("size of a bid- {0}", depot.Length);
Console.WriteLine("bid1 {0}", bid1);
Console.WriteLine(depot.CanRead);
Bid bid2 = (Bid)formatter.Deserialize(depot);
Console.WriteLine("bid2 {0}", bid2);
depot.Close();
}
results in this:
...\bin\Debug>consoleapplication1
size of a bid- 226
bid1 23:10:3:0:052405160487
True
Unhandled Exception:
System.Runtime.Serialization.SerializationExceptio n: End of
Stream encountered before parsing was completed.
Bid is:
struct Bid {
int p;
float o;
int b;
short w;
string tS;
which, in a constructor, converts the DateTime to a formatted string.
I've tried commenting out the depot.Close and setting the initial size
to 226 with identical results.
thx
md
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!