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 ?