XML序列化和对象数据宾格列表的避免问题
我尝试序列化并逐个序列化XML文件。 C#中的代码在寡妇上非常有效。但是,当我尝试使用单声道在Ubuntu上进行操作时,它将无法使用对象的数据列表。该过程是在6个嘴巴工作。这似乎不是Ubuntu或单声道问题,因为我使用了它们的最新版本和3年前的版本。我在Windows 10上使用“ Oracle WM VirtualBox 6.0”。
在BindingList的序列化项目中,未重载(而不是在XML文件上写入)。在线路上的挑战崩溃是bindingdatalist的第一项,其中有错误:“ system.uriformatexception:无效的uri:无法确定URI的格式。”
这可能是一个具有约束力的问题或高级XML标记的问题。也许XML太嵌套了。
在这里我要序列化/挑选序列化:
[Serializable, XmlInclude(typeof(WeatherFileFormat)), Bindable(true)]
public class WeatherFile : Child<string>, IWithPath
{
private string relativeFileName;
[XmlAttribute(AttributeName = "file")]
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string File
{
get {
return "../MyFile.txt";
}
set
{
relativeFileName=newRelativeFileName="../MyFile.txt"
}
}
}
[Serializable, XmlInclude(typeof(WeatherFile)),XmlInclude(typeof(WeatherFileFormat)), XmlInclude(typeof(BaseBindingList<WeatherFile>))]
public class SiteItem : ProjectDataFileItem1Child<WeatherFile, string, WeatherFileGenerator>, IWithPath
{
[XmlElement("WeatherFiles",typeof(BaseBindingList<WeatherFile>))]
public BaseBindingList<WeatherFile> WeatherFiles { get { return BindingItems1; }}
}
这是我在序列化过程中获得的:
<?xml version="1.0">
<SiteItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-instance" name="" format="YearJdayMinMaxRainRad">
<WeatherFiles />
</SiteItem>
为了简单的依据,我总结了代码和XML。例如,“名称”和“格式”是“ siteItem”的属性,这些属性在本文中未表示,但可以很好地考虑到它们。
这是我试图进行挑选的:
<?xml version="1.0">
<SiteItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-instance" name="MyName" format="YearJdayMinMaxRainRad">
<ItemArray>
<WeatherFiles>
<WeatherFile file=""../MyFile.txt"" />
</WeatherFiles>
</ItemArray>
</SiteItem>
它在生产线上崩溃了
。
I try to serialize and deserialize an xml file. The code in C# works perfectly well on Widows. But when I try to do it on ubuntu with mono, It fails for DataBindingList of Objects. The process was working 6 mouths ago. It doesn't seem like it is a ubuntu or a mono version problem since I used both the most recent versions of them and 3 years ago versions. I use the "Oracle WM VirtualBox 6.0" on Windows 10.
During the serialization items of the BindingList are not regonized (and not writen on the xml file). And the deserialization crash at the line where is the first item of the BindingDataList with the error: "System.UriFormatException: Invalid URI: The format of the URI could not be determined."
It could be a binding problem or a problem of high level xml mark. Maybe the xml is too nested.
Here What I want to serialize/deserialize:
[Serializable, XmlInclude(typeof(WeatherFileFormat)), Bindable(true)]
public class WeatherFile : Child<string>, IWithPath
{
private string relativeFileName;
[XmlAttribute(AttributeName = "file")]
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string File
{
get {
return "../MyFile.txt";
}
set
{
relativeFileName=newRelativeFileName="../MyFile.txt"
}
}
}
[Serializable, XmlInclude(typeof(WeatherFile)),XmlInclude(typeof(WeatherFileFormat)), XmlInclude(typeof(BaseBindingList<WeatherFile>))]
public class SiteItem : ProjectDataFileItem1Child<WeatherFile, string, WeatherFileGenerator>, IWithPath
{
[XmlElement("WeatherFiles",typeof(BaseBindingList<WeatherFile>))]
public BaseBindingList<WeatherFile> WeatherFiles { get { return BindingItems1; }}
}
This is what I obtain during serialization:
<?xml version="1.0">
<SiteItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-instance" name="" format="YearJdayMinMaxRainRad">
<WeatherFiles />
</SiteItem>
For the sake of simplycity I sum up the code and the xml. For example "name" and "format" are attribute of "SiteItem" which are not represented in this post but which are well taken into account.
Here is what I try to deserialize:
<?xml version="1.0">
<SiteItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-instance" name="MyName" format="YearJdayMinMaxRainRad">
<ItemArray>
<WeatherFiles>
<WeatherFile file=""../MyFile.txt"" />
</WeatherFiles>
</ItemArray>
</SiteItem>
It crashes at the line were appears the mark WeatherFile
Does anyone has an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论