我试图通过反序列化加载一个类。我有一个XML文件及其XSD文件,我使用XSD.EXE程序生成了C#类。我已将在互联网上找到的代码转换为VB。应用程序编译好,但在到达新代码之前崩溃。当我删除加载代码时,应用程序正常运行。错误:
未处理的类型' System.InvalidOperationException'发生在System.Xml.dll
中其他信息:反映类型的错误' ActuarialStuff.TablesSOA'。
源XML:
<?xml version="1.0" encoding="utf-8"?>
<SOATables>
<XTbML>
</XTbML>
.
.
.
<XTbML>
</XTbML>
<SOATables>
目标对象:
<System.Serializable>
<System.Xml.Serialization.XmlRoot("SOATables")>
Public Class TablesSOA
<XmlArray("SOATables")>
<XmlArrayItem("XTbML", GetType(XTbML))>
Public Property TabSOA() As XTbML
End Class
正在加载代码:
Dim path As String = "O:\OneDrive\Documents\Actuarial Stuff\SOATables\SOA.XML"
Dim tSOA As TablesSOA
Dim ser As XmlSerializer = New XmlSerializer(GetType(TablesSOA))
Using reader As XmlReader = XmlReader.Create(path)
tSOA = CType(ser.Deserialize(reader), TablesSOA)
End Using
谢谢,
基思