The following defines the structures I am attempting to serialize. I think I have the xml decoration correct - but the errors I'm receiving (see below) don't really give me much information.
Expand|Select|Wrap|Line Numbers
- Imports System.IO
- Imports System.Xml.Serialization
- Public Module modTestSerialization
- Friend ActiveRO() As ActiveROType
- Friend ActiveROCount As Integer
- Friend bNoReEntry As Boolean = False
- <Serializable()> Public Structure ActiveROStoriesType
- <XmlAttribute("StorySlug")> Public StorySlug As String
- <XmlAttribute("StoryStoryID")> Public StoryID As String
- <XmlElement("StoryBody")> Public StoryBody As String
- End Structure
- <Serializable()> Public Structure ActiveROType
- <XmlAttribute("ROid")> Public ROID As String
- <XmlAttribute("ROName")> Public ROName As String
- <XmlArrayItem("ROStories")> Public ROStories() As ActiveROStoriesType
- End Structure
- Friend Function UpdateROInfo(ByVal AllROs() As ActiveROType) As Boolean
- Dim fs As New FileStream("c:\mos\queue\fromNCS\ActiveROTest.xml", FileMode.Create)
- Dim xs As New XmlSerializer(GetType(ActiveROType))
- xs.Serialize(fs, AllROs)
- fs.Close()
- End Function
- End Module
Expand|Select|Wrap|Line Numbers
- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Static I As Integer = -1
- I += 1
- ReDim Preserve ActiveRO(I)
- ReDim Preserve ActiveRO(I).ROStories(2)
- With ActiveRO(I)
- .ROID = "RO" & I.ToString
- .ROName = "MyRunningOrder-" & I.ToString
- For J As Integer = 0 To 2
- With ActiveRO(I).ROStories(J)
- .StoryID = "StoryID" & J.ToString
- .StorySlug = "Slug" & J.ToString
- .StoryBody = "Now is the time for all good men to come to the aid of their country."
- End With
- Next J
- End With
- UpdateROInfo(ActiveRO)
- End Sub
- End Class
InnerException: When casting from a number, the value must be a number less than infinity.
InnerException: Make sure the source type is convertible to the destination type.