Quantcast
Viewing all articles
Browse latest Browse all 12583

Problem with the serialization XML (VB.Net, wpf application)

Hi,I have problem with my serialization. I have an object that contains a list of other objects. I need to serialize this object but always get an error. The principal Object is called "DataGeneraleAudit". The error is: 
"An error occurred during the reflection type"
 
Here is my object 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" Public _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  End Class

As you can see in the code, I create an object from a list of DataAudit. The Object DataAudit is compose for differents methodes and property and objects too.
 
Here is the Object "DataAudit":

Public Class DataAudit   #Region "Declarations"  Private _Technologie As New DataTechnologie Private _Acquisition As New DataAcquisition Private _Resultats As New DataResultats  #End Region   #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 ResultaAs As DataResultats Get Return _Resultats End Get  Set(ByVal value As DataResultats) _Resultats = value End Set End Property  #End Region  #Region "Méthodes"  Public Sub New() End Sub   #End Region  End Class

and finally, here is the serialization:

Public Class MainWindow
    Public Sub New() 
        ' This call is required by the designer.
        InitializeComponent() 
        ' Add any initialization after the InitializeComponent() call.

    End Sub
 Friend nomFichierConfigXml As String
    Friend Config As New DataGeneraleAudit
 
 Private Sub MainWindow_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing 
        Try 
            ' Sérialization XML...
            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

Where is the problem please? Somebody can help me?
Thank you

Langage: VB.NET, WPF Application




Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>