473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Serialize and deserialize

I got something like this in VB.Net

<Serializable()> Public Class YQProfileC
Inherits CollectionBase
Public Sub Save2File(ByVal FileName As String)
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Create,
FileAccess.Write, FileShare.None)
IFormatter.Serialize(FS, Me)
FS.Close()
End Sub

Public Function LoadFromFile(ByVal FileName As String) As YQProfileC
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Open,
FileAccess.Read, FileShare.None)
Return IFormatter.Deserialize(FS)
End Function
End Class

Now I got two problem here:
1.For some reason, the Root space name of the project needs to be changed
from YQV020 to YQV. But after that, how could I deserialize the old file.
2.What would have been done to deserialize the file if we want o change the
code from VB.net to C#.net? Please don't ask me why.

Thanks very much.
Amsteel
Nov 20 '05 #1
2 1391
Amsteel,
1.For some reason, the Root space name of the project needs to be changed
from YQV020 to YQV. But after that, how could I deserialize the old file. The following three part article covers binary serialization in detail:
http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

I believe the third one discusses what to do if the namespace changes.
2.What would have been done to deserialize the file if we want o change the code from VB.net to C#.net? Please don't ask me why. Changing from VB.NET to C# should not effect anything, as long as both types
are "exactly" the same. For the change in the 'name' (version number really)
you can use the code in the above articles.

Hope this helps
Jay

"Amsteel" <z2***@hotmail.com> wrote in message
news:MS*****************@news01.bloor.is.net.cable .rogers.com... I got something like this in VB.Net

<Serializable()> Public Class YQProfileC
Inherits CollectionBase
Public Sub Save2File(ByVal FileName As String)
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Create,
FileAccess.Write, FileShare.None)
IFormatter.Serialize(FS, Me)
FS.Close()
End Sub

Public Function LoadFromFile(ByVal FileName As String) As YQProfileC
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Open,
FileAccess.Read, FileShare.None)
Return IFormatter.Deserialize(FS)
End Function
End Class

Now I got two problem here:
1.For some reason, the Root space name of the project needs to be changed
from YQV020 to YQV. But after that, how could I deserialize the old file.
2.What would have been done to deserialize the file if we want o change the code from VB.net to C#.net? Please don't ask me why.

Thanks very much.
Amsteel

Nov 20 '05 #2
Thanks, it looks like I got a lot of reading to do.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
Amsteel,
1.For some reason, the Root space name of the project needs to be changed from YQV020 to YQV. But after that, how could I deserialize the old file.
The following three part article covers binary serialization in detail:
http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

I believe the third one discusses what to do if the namespace changes.
2.What would have been done to deserialize the file if we want o change the
code from VB.net to C#.net? Please don't ask me why.

Changing from VB.NET to C# should not effect anything, as long as both

types are "exactly" the same. For the change in the 'name' (version number really) you can use the code in the above articles.

Hope this helps
Jay

"Amsteel" <z2***@hotmail.com> wrote in message
news:MS*****************@news01.bloor.is.net.cable .rogers.com...
I got something like this in VB.Net

<Serializable()> Public Class YQProfileC
Inherits CollectionBase
Public Sub Save2File(ByVal FileName As String)
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Create,
FileAccess.Write, FileShare.None)
IFormatter.Serialize(FS, Me)
FS.Close()
End Sub

Public Function LoadFromFile(ByVal FileName As String) As YQProfileC
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Open,
FileAccess.Read, FileShare.None)
Return IFormatter.Deserialize(FS)
End Function
End Class

Now I got two problem here:
1.For some reason, the Root space name of the project needs to be

changed from YQV020 to YQV. But after that, how could I deserialize the old file. 2.What would have been done to deserialize the file if we want o change

the
code from VB.net to C#.net? Please don't ask me why.

Thanks very much.
Amsteel


Nov 20 '05 #3

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

Similar topics

7
by: Ian Tompsett | last post by:
H I was wondering if it possible for an object to serialize/deserialize itself from XML. I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a...
14
by: vince | last post by:
Can I add (append) to an xml file that already contains a serialized object, and be able to deserialize to either or both objects from the same file...??? How is this done...?? thanks, vince
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
2
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
2
by: Joe | last post by:
Hi I have a Generics List in a PropertyGrid I am able to Serialize it to XML but when I try to deserialize back to the class of the PropertyGrid The Constructor doesn't seem to fire to reload...
4
by: Hone | last post by:
I'm trying to serialize/deserialize the XML for an RSS 1.0 Feed (i.e. RDF) and the root element, as required by the standard, looks like this: <rdf:RDF ...> </rdf:RDF> However, I've tried...
4
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
4
by: djidan | last post by:
hi, i am a newbe to c#, i'm trying to send en custom object from a client to a server, after reading a lot on the web ifound that i need to use: BinaryFormatter, MemoryStream, and Serialize...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.