473,783 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deserialization Error--End Of Stream

Hello,

I am attempting to serialize an object for storage in a DB field and them deserialize it later on. I have managed to Serialize it using

private string SerializeObject (object ObjectToSeriali ze)
{
MemoryStream ms = new MemoryStream();
string theSerializedOb ject;

System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er formatter = new System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
try
{
formatter.Seria lize(ms, ObjectToSeriali ze);
byte[] thisByteArray = ms.ToArray();
theSerializedOb ject = Convert.ToBase6 4String(thisByt eArray);
}
catch (System.Runtime .Serialization. SerializationEx ception e)
{
Logs.WriteToLog ("Error Serializing " + ObjectToSeriali ze.GetType().To String() + " Object: " + e.Message);
throw;
}
finally
{
ms.Close();
}

return theSerializedOb ject;
}
I store the string returned by the above method in the DB. But I am having to trouble Deserializing it. I have the following method:

private object DeserializeObje ct(string StringToDeseria lize)
{
object thisDeserialize dObject = null;
byte[] thisByteArray = Convert.FromBas e64String(Strin gToDeserialize) ;
MemoryStream ms = new MemoryStream(th isByteArray);
try
{
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er formatter = new System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();

thisDeserialize dObject = formatter.Deser ialize(ms);
}
catch (System.Runtime .Serialization. SerializationEx ception e)
{
Logs.WriteToLog ("Error Deserializing " + StringToDeseria lize + " String: " + e.Message);
throw;
}
finally
{
ms.Close();
}

return thisDeserialize dObject;
}

The deserialized method raises an error saying "End of Stream encountered before parsing was completed." when it reaches

thisDeserialize dObject = formatter.Deser ialize(ms);

What might be causing this? I could provide some sample data if it would help. Thanks for your help!
Nov 18 '05 #1
1 1305
Hi,

As for this post. I've replied you in another duplicated one in this group.
I'd appreciate if you have a look there. Also, if you feel convenient that
we continue to discuss in that thread, please feel free to follow up there
..Thanks.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2

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

Similar topics

1
2084
by: Tom L | last post by:
Simple deserialization help needed please... I have a packet of xml in a string, and need to get that into a reader./stream of some sort so I can properly use deserialize.. here's my deserialization routine (its part of a property as you can tell).. Set(ByVal Value As String) Dim serializer As New XmlSerializer(GetType(Package)) Dim xmlstream As New MemoryStream
2
9452
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and...
3
2082
by: Roy Chastain | last post by:
The following code fails with an exception of "There is an error in XML document (2, 2)." string with an inner exception of "Value cannot be null.\r\nParameter name: input" string. The inner exception has a strack trace of " at System.Text.RegularExpressions.Regex.Split(String input, Int32 count)\r\n at KMS.Licensing.LicenseBase.Parse() in c:\\kms\\licensing\\common\\licensebase.cs:line 672\r\n at...
1
12063
by: BH | last post by:
I'm trying a simple object serialization and deserialization, and keep getting this error: System.Runtime.Serialization.SerializationException: Binary stream does not contain a valid BinaryHeader, 0 possible causes, invalid stream or object version change between serialization and deserialization. Here's my code. it does nothing but to serialize a DataTable object into a byte array, and then read the byte array back for...
3
9796
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
3
2069
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
2
1775
by: andreas | last post by:
Hi, if have a object arrSdList of type SortedList for serialization and deserialization there are two subs for doing this Public Sub deser Dim Formatter As BinaryFormatter = New BinaryFormatter() Dim ReadFile As FileStream ReadFile = File.OpenRead(FilePad)
3
9795
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
8
3470
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a requirement to have a server web service class. (reasons below) 3. I want to develop something like this - when client makes a web service call, on the server I can intercept the SOAP message (XML doc itself),
1
4951
by: depalau | last post by:
I'm experiencing issues where XmlSerialier.Deserialize throws an exception when attempting to use a MemoryStream built with an XmlWriter vs. a standalone StringReader. It is attempting to deserialize a complex object. Here is what I have: 0. Environment: Visual Studio 2005, VB.Net. I won't go into the gory details of my complex object, just suffice to say that I need to return XML instead of the object directly from the web service....
0
9643
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.