I'm trying to serialize some public class, but it doesn't compleate correctly, I receive an error message that class is not public. there is an all code of my console application (from MSDN):
Code:
Imports System.IO
Imports System.Xml.Serialization
Module Module1
Sub Main()
SerializeObject("person.xml")
End Sub
Private Sub SerializeObject(ByVal filename As String)
Dim serializer As New XmlSerializer(GetType(OrderedItem))
' Create an instance of the class to be serialized.
Dim i As New OrderedItem()
' Set the public property values.
With i
.ItemName = "Widget"
.Description = "Regular Widget"
.Quantity = 10
.UnitPrice = CDec(2.3)
End With
' Writing the document requires a TextWriter.
Dim writer As New StreamWriter(filename)
' Serialize the object, and close the TextWriter.
serializer.Serialize(writer, i)
writer.Close()
End Sub
' This is the class that will be serialized.
Public Class OrderedItem
Public ItemName As String
Public Description As String
Public UnitPrice As Decimal
Public Quantity As Integer
End Class
End Module
how can i resolve this issue?