473,543 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BinaryFormatter/Serialization Problem with Threads

Hi,

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. SerializationEx ception' occurred in
mscorlib.dll
Additional information: End of Stream encountered before parsing was
completed.

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.Scrat ch, Version=1.0.220 5.36835,
Culture=neutral , PublicKeyToken= null *PIF.Core.Scrat ch.Final.Campai gner
fulfillmentEve nt _visitsLeft_id 
3PIF.Core.Scrat ch.Final.Fulfil lmentHandler2 
– 

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

 ˇˇˇˇ  WPIF.Core.Scrat ch, Version=1.0.220 5.36835,
Culture=neutral , PublicKeyToken= null *PIF.Core.Scrat ch.Final.Campai gner
fulfillmentEve nt _visitsLeft_id 
"System.Delegat eSerializationH older
 . ź

Notice the second to last line. When serializing in a simple console, the
PIF.Core.Scratc h.Final.Fulfill mentHandler2 type is written out, but in the
thread example, System.Delegate SerializationHo lder is written out...? ??

The classes Campaigner, FulfillmentHand ler2 and FulfillmentSeri alizer all
live in the same namespace and assembly, PIF.Core.Scratc h.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
(http://www.cs.odu.edu/~jmayor/cs477/...or_NET1_1.htm),
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!

J.
Jan 14 '06 #1
0 876

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3792
by: Dominic | last post by:
Hi everybody, In my application, I'm planning to use BinaryFormatter to serialize a potentially huge object to file (and, of course, deserialize back to memory later). My question is if there is any hard limit on the size of this object? Is it only limited by the amount of memory or hard-disk space in the server?
5
3802
by: aladdinm1 | last post by:
Hi All, I have an annoying trouble with binary serialization. I have a windows forms application which works like a server and keeps sending data to its clients. The data is serialized before being sent using BinaryFormatter and a serializable object. When using a windows forms application as a client, everything works just fine and...
3
5463
by: Joshua Moore | last post by:
I have a webservice that serializes a ton of variables and other good stuff to a txt file using SoapFormatter (IFormatter), and when I try to deserialize it using the binary formatter, i get the following error: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1986938170.1886350437. I've read a lot...
11
3927
by: Igor | last post by:
Hi. While executing BinaryFormatter.Deserialize() I get: System.InvalidCastException: Specified cast is not valid. I implemented ISerializable interface. What may be a problem? Thanks.
0
2062
by: Fruber Malcome | last post by:
I'm getting a very weird exception and hoping someone may be able to help. I have an Office Add-In that lives in a .dll (for email reference ai.dll) ai.dll makes calls into the core part of the application implementation in another .dll (let's call that app.dll). app.dll makes a function call into another dll (let's call that one dep.dll)....
19
6207
by: Sharon | last post by:
Hi, When I'm doing BinaryFormatter.Deserialize() over a TCP socket. When I'm closing the TcpListener by invoking the TcpListener.Stop(); I get: System.IO.IOException with message "Unable to read data from the transport connection." that InnerException of type System.Net.Sockets.SocketException saying "An established connection was...
2
5808
by: Doug Lind | last post by:
Hi all, I have seen a number of posts re: the BinaryFormatter version incompatibility but nothing on how to recover from it. In my case, I want the exception to trigger an alternate behaviour and continue process the stream. My app reads and writes configuration settings to a binary file upon starting and shutdown. The settings are...
2
1481
by: Lambuz | last post by:
Hi all, I'm triying to create a prototype of a smart client that using .NET Remoting. I've got an assembly loaded into an HTML page by a tag object <OBJECT id="myID" height="150" width="300" classid="http:bin/CPRSWebClient.dll#IBM.Cipros.Refinery.CPRSWebClient" /> My assembly is strong named and it is full trusted.
1
2279
by: Tarscher | last post by:
Hi all, i want to save my application to a file with a BinaryFormatter . I have some questions how the BinaryFormatter will work when the I update my application. How can I make sure that I can still read older saved files. I looked for a tutorial but can't seem to find one. Someone has experience with BinaryFormatter and versioning?
0
7408
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main...
0
7590
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5271
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
636
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.