无法生成临时类(结果=1).错误 CS0030:无法将类型“

Unable to generate a temporary class (result=1). error CS0030: Cannot convert type #39;Type[]#39; to #39;Type#39;?(无法生成临时类(结果=1).错误 CS0030:无法将类型“Type[]转换为“Type?)

本文介绍了无法生成临时类(结果=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:无法将类型“

基础教程推荐