Results 1 to 6 of 6

Thread: Serialization in Vb.net

  1. #1
    Join Date
    Nov 2009
    Posts
    678

    Serialization in Vb.net

    Hello, I want to know the details about the Serialization in vb.net. I want to learn the vb.net programming language but,this point I am not getting from my reference book. If you are having details about it, then please help me to achieve the details about it. I will be thankful to your. So, please help me to know it.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Serialization in Vb.net

    Serialization in Vb.net makes use of the some of the following classes which are useful to it.
    • Formatter:
      This is the class which is used for the purpose of the writing object data with the format which can be read by the output stream while displaying output. If you perform the deserialization operation then that can perform by this class.
    • ObjectIDGenerator:
      This is useful for creating a IDs for different objects. As it remembers the previous created ids it will simply create new ID for new object and uses the older id for existing object.
    • ObjectManager:
      It will work for the keeping the track of the objects which are being deserialized.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Serialization in Vb.net

    For the purpose of the serialization in Vb.net I have got the code below:
    Code:
    Option Strict We
    Option Explicit 
    Imports System.IO
    Imports System.Runtime.Serialization.Formatters.Binary
    Public Class SerialDeserialLameGrid
    Public num As Integer
    Public num2 As Integer
    Private Grille (num, num2) As String
    Public Property grid () As Array
    Get
    grid = Grille
    End Get
    Set(ByVal value As Array)
    Grille = CType(value, String(,))
    End Set
    End Property
    
    Public Sub SerialiseLameGrid (ByVal path As String, ByVal Nbline As Integer, 
    ByVal number As Integer, ByVal Matrix (,) As String, 
    ByVal ctrl As LameGrid.Grid)
    
    Sun flux As Stream File.Create = (path) 'preparation flow
    Sun serializer As New BinaryFormatter
    For x = 0 To Nbline - 1 'For each row
    For y = 0 To number - 1 'For each column
    Grid (x, y) = ctrl (x, y). Text 'fill a table with lamegrid
    Me. Grille = Grid 'we set the table to the object grid
    Next
    Next
    serializer.Serialize (flux, Me. Grille) 'we serialize
    flux.Flush ()
    flux.Close()
    flux.Dispose ()
    End Sub
    Public Sub DeserialiseLamegrid (ByVal path As String, ByVal Nbline As Integer, 
    ByVal number As Integer, ByVal Matrix (,) As String, 
    ByVal ctrl As LameGrid.Grid)
    
    Sun flux As Stream File.OpenRead = (path) 'is prepared feeds
    Sun Deserializer As New BinaryFormatter
    
    
    Me. Grille = CType(deserializer.Deserialize (flux) String(,)) 'on the file to deserialize the object grid
    Matrix = CType(Me. Grille, String(,)) 'you put the object in a grid array
    
    For x = 0 To num
    For y = 0 To num2
    ctrl (x, y). Text = Grid (x, y) 'we fill the table since lamegrid
    Next
    Next
    ctrl.Refresh ()
    flux.Close()
    flux.Dispose ()
    End Sub
    End Class

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Serialization in Vb.net

    If you want to create a class of the Serializable then you can simply create it with the following:
    Code:
    <Serializable()> _
    Class SerializeTest
        Dim str As String
        Public Property StudName() As String
                  Get
                      Return str
            End Get
                  Set(ByVal value As String)
                      str = value
            End Set
        End Property
    End Class

  5. #5
    Preator Guest

    Re: Serialization in Vb.net

    If you want to create a serializable object then you need to follow the steps below:
    • Creating the class for serilalizable object is as similar as your normal class, but you just need to inherit from the SerializableObject instead of Object.
    • Then you need to add the counstructor as Public Sub New().
    • Then it is necessary to create a constructor as a protected and then simply call to the base class de-serialization constructor.
    • And you also need to mark your class as a <Serializable> attribute.

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Serialization in Vb.net

    If you want to create a class as a Serializatble in Vb.net then you need to use the syntax below:
    Code:
       <Serializable()> _
          Public Class vbtest
             ...
          End Class
    If you want to create a class as a Serializatble in C# then you need to use the syntax below:
    Code:
       [Serializable]_
          public class C#test
          {
             ...
          }

Similar Threads

  1. Advantages of serialization
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 06-02-2010, 11:51 AM
  2. Portable serialization
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 10:19 AM
  3. C sharp Serialization
    By Truster in forum Software Development
    Replies: 5
    Last Post: 14-01-2010, 08:40 AM
  4. What does serialization mean in java?
    By Honorata in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 08:35 AM
  5. Some questions regarding serialization
    By MABON in forum Software Development
    Replies: 3
    Last Post: 13-11-2009, 04:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,438,608.21313 seconds with 16 queries