Bonjour,
Je cherche à sérialiser en XML un objet qui est crée par des classes qui dépendent les unes des autres, mais j’obtiens l'erreur :
voici les classes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part InvalidCastException*: Impossible d'effectuer un cast d'un objet de type 'Asc_to_GMA3.GMA3' en type 'System.Collections.Generic.List`1[Asc_to_GMA3.GMA3]'.
7
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126 Public Class GMA3 Public Property DataVersion As String = "2.1.1.2" Public Property Sequence As Sequence End Class Public Class Sequence Public Property Name As String = "conduite_import" Public Property Guid As String = "4E D8 34 5E 00 01 01 00 BB 4A 29 00 63 7F AF 03" Public Property AutoStart As String = "Yes" Public Property AutoStop As String = "No" Public Property AutoFix As String = "No" Public Property AutoStomp As String = "Yes" Public Property SoftLTP As String = "Yes" Public Property XFadeMode As String = "Split" Public Property XFadeReload As String = "No" Public Property SwapProtect As String = "Yes" Public Property KillProtect As String = "Yes" Public Property UseExecutorTime As String = "Yes" Public Property OffwhenOverridden As String = "No" Public Property SequMIB As String = "Enabled" Public Property SequMIBMode As String = "Late" Public Property AutoPrePos As String = "No" Public Property WrapAround As String = "No" Public Property MasterGoMode As String = "None" Public Property SpeedfromRate As String = "Yes" Public Property Tracking As String = "Yes" Public Property IncludeLinkLastGo As String = "Yes" Public Property RateScale As String = "One" Public Property SpeedScale As String = "One" Public Property PreferCueAppearance As String = "No" Public Property ExecutorDisplayMode As String = "Both" Public Property Cues As Cue End Class Public Class Cue Public Property Name As String = "" Public Property No As Integer Public Property Assert As String = "Assert" Public Property AllowDuplicates As String = "" Public Property TrigType As String = "" ' c'est le go, le follow ou le time Public Property Parts As Part End Class Public Class OffCue Public Property Name As String = "OffCue" Public Property Release As String = "Yes" Public Property Assert As String = "Assert" Public Property AllowDuplicates As String = "" End Class Public Class Cue_Zero Public Property Name As String = "CueZero" Public Property No As Integer = 0 Public Property Parts As Part End Class Public Class Part Public Property Name As String = "" Public Property Guid As String = "DB D3 42 AA 5C 01 10 06 17 88 4D FD F6 02 86 1F" Public Property AlignRangeX As String = "No" Public Property AlignRangeY As String = "No" Public Property AlignRangeZ As String = "No" Public Property PreserveGridPositions As String = "No" Public Property MAgic As String = "No" Public Property Mode As String = "0" Public Property Sync As String = "" Public Property Morph As String = "" Public Property CueInFade As String = "3.000" Public Property CueInDelay As String = "" Public Property CueOutFade As String = "" Public Property CueOutDelay As String = "" Public Property Part As Integer = "" ' si il y a une part dans la cue alors part =1 si il y a 1 part en plus de la cue, =2 si il y a 2 part en plus Public Property MIBMode As String = "None" Public Property PresetData As PresetData Public Property dependencyExport As DependencyExport End Class Public Class DependencyExport ' C'EST LES PRESETS Public Property Size As Integer = 1 Public Property Dependencies As Dependency End Class Public Class Dependency ' C'EST LES PRESETS Public Property RelAddr As String = "ShowData.DataPools.Default.PresetPools.Color.'L 502'" Public Property RelAddrNum As String = "13.13.1.4.4.352" Public Property Address As String = "ShowData.DataPools.Default.PresetPools.Color.'L 502'" Public Property AddressNum As String = "13.13.1.4.4.352" Public Property Preset As Preset End Class Public Class Preset Public Property Name As String = "L 502" Public Property Guid As String = "F2 09 37 5E 00 01 01 00 C4 4A 29 00 69 33 E5 3C" Public Property Active As String = "No" Public Property ShuffleMode As String = "Auto" Public Property XWidth As String = "None" Public Property YWidth As String = "None" Public Property ZWidth As String = "None" Public Property PresetData As PresetData End Class Public Class PresetData ' CONTENU DE LA CUE POUR LES INTENSITES Public Property Size As Integer Public Property Phasers As Phaser End Class Public Class Phaser Public Property IDType As Integer = 1 Public Property ID As Integer Public Property Attribute As String = "Dimmer" Public Property Steps As [Step] End Class Public Class [Step] Public Property [Function] As String Public Property Absolute As Double End Class
et voici le code pour serialiser :
pouvez-vous m'aider je ne sais pas ce qui ce passe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Dim gma3bis As New GMA3 Dim serializer As New XmlSerializer(GetType(List(Of GMA3))) ' Dim writer As New XmlTextWriter("C:\Users\hp-bureau\Desktop\test-premier-export.xml", Encoding.UTF8) Using writer As New StreamWriter("C:\Users\hp-bureau\Desktop\test-premier-export.xml") serializer.Serialize(writer, gma3bis) End Using
Merci d'avance.
Partager