is not marked as serializable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amirghaffarie1362
    New Member
    • Jan 2009
    • 19

    is not marked as serializable

    i use below code for create arraylist()
    Code:
    
     Dim ItemsT As New ArrayList()
            If ViewState("items") IsNot Nothing Then
                ItemsT = DirectCast(ViewState("items"), ArrayList)
            Else
                ItemsT = New ArrayList()
            End If
            Dim itemID As Integer = EasyListBoxItemT.SelectedValue
            Dim count As String = TextBoxCount.Text
            Dim Dv As Data.DataView
            Dv = ListData.vag_list_GetItem(itemID).Tables(0).DefaultView
            Dim name As String = Dv.Item(0).Item("name")
            Dim Code As String = Dv.Item(0).Item("Code")
            Dim additem As ItemInf = New ItemInf()
            additem.ID = itemID
            additem.Code = Code
            additem.count = count
            additem.Name = name
            ItemsT.Add(additem)
            ViewState("items") = ItemsT
            TextBoxCount.Text = ""
            EasyListBoxItemT.ClearSelection()
    
    
    Public Class ItemInf
        Public itemID As Integer
        Public _Name As String
        Public _Code As String
        Public _count As String
        'Public Sub New(ByVal itemid As Integer, ByVal name As String, ByVal code As String, ByVal count As String)
        '    Me.itemID = itemid
        '    Me._Code = code
        '    Me._count = count
        '    Me._Name = name
        'End Sub
        Public Property ID() As Integer
            Get
                Return itemID
            End Get
            Set(ByVal value As Integer)
                itemID = value
            End Set
        End Property
        Public Property Name() As String
            Get
                Return _Name
            End Get
            Set(ByVal value As String)
                _Name = value
            End Set
        End Property
        Public Property Code() As String
            Get
                Return _Code
            End Get
            Set(ByVal value As String)
                _Code = value
            End Set
        End Property
        Public Property count() As String
            Get
                Return _count
            End Get
            Set(ByVal value As String)
                _count = value
            End Set
        End Property
    End Class
    But i got this error :
    Type 'ItemInf' in Assembly 'App_Code.pnpn3 1qh, Version=0.0.0.0 , Culture=neutral , PublicKeyToken= null' is not marked as serializable

    any sugestion ??
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Well, if at any point in your program you require objects of type ItemInf to be serialized than you need to mark the class ItemInf as serializable.

    Comment

    • amirghaffarie1362
      New Member
      • Jan 2009
      • 19

      #3
      yes i found out i just should add <Serializable() > _ above the class

      Comment

      Working...