Print Page | Close Window

DeSerialization

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1974
Printed Date: 20-Sep-2025 at 9:48am


Topic: DeSerialization
Posted By: DjStitch
Subject: DeSerialization
Date Posted: 19-Jul-2010 at 6:16am
Hi there.
 
I just cant seem to get this right, after Serialization my objects graph using NetDataContractSerializer i want ot use the same file to DeSerialization it back to the objects but i get an error. Please tell me what i'm doing wrong
Here is my code:
 

Dim serializer = New NetDataContractSerializer() ' simpler because no need for

Dim ms = New MemoryStream()

Dim writer = System.Xml.XmlDictionaryWriter.CreateTextWriter(ms)

serializer.WriteObject(writer, g_Cust_Main)

writer.Flush()

ms.Position = 0

Dim result = StreamFns.ToString(ms)

WriteReplyFile(sFileName, result)

Public Function ReturnObject(ByVal fileName As String) As cust_main

'Console.WriteLine("Deserializing an instance of the object.")

Dim fs As New FileStream(fileName, FileMode.Open)

Dim serializer As New System.Runtime.Serialization.NetDataContractSerializer()

' simpler because no need for

Dim reader As XmlDictionaryReader = XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())

Dim acust_main As cust_main = CType(serializer.ReadObject(reader, True), cust_main)

reader.Close()

fs.Close()

Return acust_main

End Function

 
The reason why i'm using Serializer is i want toi interact with anoter system / software and if I use

_ServerMgr.CacheStateManager.SaveCacheState the data is not readable, is there maybe another way i can aprotch this ?

 
  



Replies:
Posted By: ting
Date Posted: 21-Jul-2010 at 7:13pm
In DevForce 2009, it is not possible to serialize an entity by itself outside of the cache.  This works in DevForce 2010 however.



Print Page | Close Window