471,350 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

BinaryFormatter/Serialization Problem with Threads


I am serializing objects on a worker thread, but when I attempt to
deserialize on a different thread, I get the error :

An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
Additional information: End of Stream encountered before parsing was

I know why there is an error, because the data written to the file on the
second thread is different to that written to a file on the main thread. I
wrote a simple test to write out a simple object in a console application,
and this is what was written:

   WPIF.Core.Scratch, Version=1.0.2205.36835,
Culture=neutral, PublicKeyToken=null *PIF.Core.Scratch.Final.Campaigner
fulfillmentEvent _visitsLeft_id

However this is what is written when the same object is written on a second
worker thread:

   WPIF.Core.Scratch, Version=1.0.2205.36835,
Culture=neutral, PublicKeyToken=null *PIF.Core.Scratch.Final.Campaigner
fulfillmentEvent _visitsLeft_id

Notice the second to last line. When serializing in a simple console, the
PIF.Core.Scratch.Final.FulfillmentHandler2 type is written out, but in the
thread example, System.DelegateSerializationHolder is written out...? ??

The classes Campaigner, FulfillmentHandler2 and FulfillmentSerializer all
live in the same namespace and assembly, PIF.Core.Scratch.Final. I am
scratching my head. Having done some research I notice changes in the 1.1
framework for security mods. affect deserialization over remoting boundaries
but I am wondering what this means for simply creating a second thread and
deserializing on it? I suspect there is something subtle here I am missing.

Any advice on this most appreciated!

Jan 14 '06 #1
0 831

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Igor | last post: by
reply views Thread by Fruber Malcome | last post: by
1 post views Thread by Tarscher | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.