njsokalski
Well-known member
- Joined
- Mar 16, 2011
- Messages
- 102
- Programming Experience
- 5-10
I have the following code that serializes an object:
Dim stream As New MemoryStream()
Dim xml As New XmlSerializer(GetType(SyncData))
xml.Serialize(stream, New SyncData(CType(Application.Current, App).Recipients, CType(Application.Current, App).Gifts))
However, when I later attempt to check whether it can be deserialized using the following code:
If New XmlSerializer(GetType(SyncData)).CanDeserialize(XmlReader.Create(stream)) Then
I receive the following error:
Data at the root level is invalid. Line 1, position 1.
The XML is all well formed, and the first line is the following:
<?xml version="1.0"?>
From what I could find, it sounds like this has something to do with encoding or some illegal character at the beginning of the file, but I am not sure how to fix it. Can anybody help me? Thanks.
Dim stream As New MemoryStream()
Dim xml As New XmlSerializer(GetType(SyncData))
xml.Serialize(stream, New SyncData(CType(Application.Current, App).Recipients, CType(Application.Current, App).Gifts))
However, when I later attempt to check whether it can be deserialized using the following code:
If New XmlSerializer(GetType(SyncData)).CanDeserialize(XmlReader.Create(stream)) Then
I receive the following error:
Data at the root level is invalid. Line 1, position 1.
The XML is all well formed, and the first line is the following:
<?xml version="1.0"?>
From what I could find, it sounds like this has something to do with encoding or some illegal character at the beginning of the file, but I am not sure how to fix it. Can anybody help me? Thanks.