Below is the code to Serialize an Object. I need this to serialize a Form and save it in the configuration of my application.
I have set a breakpoint and noticed that it returns Nothing or Null (3rd line in code below)
Public Function SerializeObject(ByVal o As Object) As String
If Not o.GetType().IsSerializable Then
Return Nothing
End If
Using stream As New MemoryStream()
Dim ser As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
ser.Serialize(stream, o)
MessageBox.Show(Convert.ToBase64String(stream.ToArray))
Return Convert.ToBase64String(stream.ToArray)
End Using
End Function
If there is alternative, I would love to know more.