Unable to generate a temporary class (result=1). error CS0030: Cannot convert type #39;Type[]#39; to #39;Type#39;?(无法生成临时类(结果=1).错误 CS0030:无法将类型“Type[]转换为“Type?)
问题描述
我使用 xsd.exe 工具从我的 xsd 文件创建了一个类后收到此错误.所以我在网上搜索并找到了解决方案.这是链接:http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html
I get this error after I created a class from my xsd file using the xsd.exe tool. So I searched the net and found a solution. Here is the link: http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html
问题是这会使代码运行,但反序列化的数据似乎已损坏.我按照网站的建议做了,最后第二个数组维度总是空的(见网站的评论,有人也有这个问题).问题是,我现在该如何解决这个问题?是否有其他工具可以创建 xsd 文件?我尝试了 Xsd2Code,但没有成功.
Problem is that this makes the code run, but somehow the deserialized data seems corrupt. I did what the site suggests and in the end the 2nd array dimension is always empty (see the comments of the site, somebody also had this problem). Question is, how do I solve this issue now? Is there another tool to create the xsd file? I tried Xsd2Code, without success.
谢谢:-)
推荐答案
需要更改序列化类中成员变量的类型.例如,如果它引发如下错误:
You need to change the type of a member variable in the serialized class. For example if its raising an error like:
无法生成临时类(结果=1).错误 CS0030:无法将类型Data[]"转换为Data".
Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Data[]' to 'Data'.
我在生成的文件中搜索了数据类型名称,发现了这个:
I ran a search on the Data type name in the generated file, and I found this:
[System.Xml.Serialization.XmlArrayItemAttribute("Data", typeof(Data), IsNullable=false)]
public Data[][] Row
将 Data[][]
替换为 Data[]
- 将 Data 的类型从 2D 数组更改为 1D 数组.它会解决你的问题.:)
Replace Data[][]
with Data[]
- Change the type of Data from a 2D array to a 1D array. It would solve your problem. :)
这篇关于无法生成临时类(结果=1).错误 CS0030:无法将类型“Type[]"转换为“Type"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法生成临时类(结果=1).错误 CS0030:无法将类型“


基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01