Regards,
In short, i'm making a WPF application. The application has 5 objects that store data. The objects are called:
DataGeneraleAudit, DataAudit, DataTechnologie, dataacquisition, DataResultat
The object DataGeneraleAudit contains a list of DataAudit object.
The object DataAudit contains the others objects: DataTechnologie, dataacquisition and DataResultat.
I want to SERIALIZE DataGeneraleAudit object for recover data from all others objects.
Here I leave the DataGeneraleAudit:
Imports System.Runtime.Serialization
Imports System.IO
Imports System.Xml.Serialization
<XmlRoot("DonneesLogiciel")> Public Class DataGeneraleAudit
Public Sub New()
End Sub
#Region "Déclaration"
Friend _DataTotale As List(Of DataAudit)
#End Region
#Region "Propiétés"
<XmlAttribute("Total")> Public Property DonneeTotale() As List(Of DataAudit)
Get
Return _DataTotale
End Get
Set(ByVal value As List(Of DataAudit))
_DataTotale = value
End Set
End Property
#End Region
#Region "Méthodes"
Public Sub New()
_DataTotale = New List(Of DataAudit)
End Sub
Public Sub AddDataTotale(ByVal AllDonnees As String)
Dim DatosTotal = New DataAudit(AllDonnees)
Me.DonneeTotale.Add(DatosTotal)
End Sub
#End Region
End Class
Now I show you the object DataAudit:
Public Class DataAudit
#Region "Declarations"
Private _Technologie As DataTechnologie
Private _Acquisition As DataAcquisition
Private _Resultats As DataResultats
Private _textNomAudit As String
Private _textDateAudit As String
#End Region
Private _allDonnees As String
Sub New(ByVal AllDonnees As String)
_allDonnees = AllDonnees
End Sub
#Region "Propiétés"
Public Property Technologie() As DataTechnologie
Get
Return _Technologie
End Get
Set(ByVal value As DataTechnologie)
_Technologie = value
End Set
End Property
Public Property Acquisition() As DataAcquisition
Get
Return _Acquisition
End Get
Set(ByVal value As DataAcquisition)
_Acquisition = value
End Set
End Property
Public Property Resultats As DataResultats
Get
Return _Resultats
End Get
Set(ByVal value As DataResultats)
_Resultats = value
End Set
End Property
#End Region
#Region "Propiétés "
Public Property _NomAudit() As String
Get
Return _textNomAudit
End Get
Set(ByVal value As String)
_textNomAudit = value
End Set
End Property
Public Property _DateAudit() As String
Get
Return _textDateAudit
End Get
Set(ByVal value As String)
_textDateAudit = value
End Set
End Property
#End Region
#Region "Méthodes"
Public Sub New()
End Sub
Public Sub AllDonneesAudit(ByVal technologie As DataTechnologie, ByVal acquisition As DataAcquisition, ByVal resultats As DataResultats, _
ByVal TextoNomAudit As String, ByVal TextoDateAudit As String, ByVal TextoNuOccupants As String)
Me.Technologie = technologie
Me.Acquisition = acquisition
Me.Resultats = resultats
Me._NomAudit = TextoNomAudit
Me._DateAudit = TextoDateAudit
End Sub
#End Region
End Class
The other objects have only a few attributes.
Finally, the class where i made the serialization (MainWindow class):
Friend Config As New DataGeneraleAudit()
Private Sub MainWindow_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
Dim xSerializer As XmlSerializer = New XmlSerializer(GetType(DataGeneraleAudit))
Dim writer As TextWriter = New StreamWriter("nomFichierConfigXml")
xSerializer.Serialize(writer, Config)
writer.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Now the problem arises when I try to serialize a DataGeneraleAudit I always get the following error:
"An error occurred During The reflection type"
As far as I found, this type of error comes from the serialization. But I could not fix it.
Could someone help me with this little problem?
thanks