New Posts New Posts RSS Feed: DeSerialization
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DeSerialization

 Post Reply Post Reply
Author
DjStitch View Drop Down
Newbie
Newbie
Avatar

Joined: 01-Oct-2008
Location: Somewhere
Posts: 24
Post Options Post Options   Quote DjStitch Quote  Post ReplyReply Direct Link To This Post Topic: DeSerialization
    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 ?

 
  
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down