Hi I have this Xml that I have to deserialize.
<datatransfer>
<start>
<msgdate>YYYYMMDD</msgdate>
<msgtime>HHMMSS</msgtime>
</start>
<details>
<sailing>
<departuredate>20100630</departuredate>
<departuretime>100000</departuretime>
</sailing>
<sailing>
<departuredate>20100710</departuredate>
<departuretime>100000</departuretime>
</sailing>
<sailing>
<departuredate>20100711</departuredate>
<departuretime>100000</departuretime>
</sailing>
</details>
<end>
<nbr>1</nbr>
</end>
Below are the classes with the get sets for the xml
<XmlRoot(ElementName:="datatransfer")> _
Public Class TtResponse
<XmlElement("start")> _
Public Property [responsestart] As responsestart
<XmlElement("response")> _
Public Property [TtResponseDetails] As List(Of TtResponseDetails)
<XmlElement("end")> _
Public Property [responseend] As responseend
End Class
<XmlRoot(ElementName:="details")> _
Public Class TtResponseDetails : Inherits List(Of Ttsailing)
Private _sailing As Ttsailing
Public Property sailing As Ttsailing
Get
Return _sailing
End Get
Set(value As Ttsailing)
_sailing = value
End Set
End Property
End Class
<XmlRoot(ElementName:="sailing")> _
Public Class Ttsailing
Private Property _departuredate As String
Private Property _departuretime As String
public Property departuredate As String
Get
Return _departuredate
End Get
Set(value As String)
_departuredate = value
End Set
End Property
Public Property departuretime As String
Get
Return _departuretime
End Get
Set(value As String)
_departuretime = value
End Set
End Property
End Class
I am deserializing using the code below and trying to display it.
Dim Samples As New List(Of TtResponse)
Dim Files As String() = Directory.GetFiles(Folder)
For Each fl In Files
Dim objStreamReader As New StreamReader(fl)
Dim i As New TtResponse
Dim x As New XmlSerializer(i.GetType)
i = x.Deserialize(objStreamReader)
Samples.Add(i)
objStreamReader.Close()
Next
Return Samples
However when I run it I get the error
Additional information: Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'System.Collections.Generic.List <test.ttresponsedetails>'
to 'test.TtResponseDetails'
error CS0029: Cannot implicitly convert type 'test.TtResponseDetails'
to 'System.Collections.Generic.List<test.ttresponsedetails>'
error CS0030: Cannot convert type 'System.Collections.Generic.List<test.ttresponsedetails>'
to 'test.TtResponseDetails'
Can anyone help me out and tell me what I'm doing wrong?