我怎样才能正确地修改生成的XSD克服一个已知的.Net错误会导致异常和QUOT; cs0030:无法生成临时类" [英] How can I correctly modify a generated XSD to overcome a known .Net bug that causes exception "cs0030:Unable to generate a temporary class"

查看:380
本文介绍了我怎样才能正确地修改生成的XSD克服一个已知的.Net错误会导致异常和QUOT; cs0030:无法生成临时类"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的职责,以数据发送到第三方网络服务,他们提供了被证明与Java客户端工作测试服务,然而,它没有在净

I have been tasked to send data to a 3rd Party web service, they have provided a test service that is proven to work with a Java client, however, it doesn't in .Net.

当我生成服务代理,要么实例化服务或连载的请求对象,我得到以下错误:

When I generate the service proxy and either instantiate the service or serialise the request object, I get the following error:

Unable to generate a temporary class (result=1). 
error CS0030: Cannot convert type 'TestStarXML.wsStarService.VSOptionInclusiveSetType[]' to 'TestStarXML.wsStarService.VSOptionInclusiveSetType' 
error CS0030: Cannot convert type 'TestStarXML.wsStarService.VSOptionConflictSetType[]' to 'TestStarXML.wsStarService.VSOptionConflictSetType'
error CS0030: Cannot convert type 'TestStarXML.wsStarService.ColorRequirementSetType[]' to 'TestStarXML.wsStarService.ColorRequirementSetType' 
error CS0030: Cannot convert type 'TestStarXML.wsStarService.ColorExclusionSetType[]' to 'TestStarXML.wsStarService.ColorExclusionSetType' 
error CS0029: Cannot implicitly convert type 'TestStarXML.wsStarService.VSOptionInclusiveSetType' to 'TestStarXML.wsStarService.VSOptionInclusiveSetType[]' 
error CS0029: Cannot implicitly convert type 'TestStarXML.wsStarService.VSOptionConflictSetType' to 'TestStarXML.wsStarService.VSOptionConflictSetType[]' 
error CS0029: Cannot implicitly convert type 'TestStarXML.wsStarService.ColorRequirementSetType' to 'TestStarXML.wsStarService.ColorRequirementSetType[]' 
error CS0029: Cannot implicitly convert type 'TestStarXML.wsStarService.ColorExclusionSetType' to 'TestStarXML.wsStarService.ColorExclusionSetType[]'

第三方发送我们的这项服务使用Java,他们也没有问题产生的测试服务的服务代理。我的理解,到目前为止是,有在.net中的错误(见这里)生成XSD的WSDL文件。

The 3rd Party that sent us this service uses Java, and they had no problem generating the service proxy from the test service. My understanding so far is that there is a bug in .Net (see here) generating the XSD for the WSDL file.

在这里答案,它提到修改生成的XSD与虚拟的属性,所以我增加了虚拟属性的建议

In the answer here, it mentions modifying the generated XSD with dummy attributes, so I added the dummy attribute as suggested:

<xs:complexType name="VSInclusivesOptionType">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="VSOptionInclusiveSet" type="tns:VSOptionInclusiveSetType" />
    </xs:sequence>
    <xs:attribute name="tmp" type="xs:string" />   <!-- this is all I have added (for each of the types in the exception message) -->
  </xs:complexType>
  <xs:complexType name="VSOptionInclusiveSetType">
    <xs:sequence>
      <xs:element minOccurs="0" name="SetID" type="ns2:IdentifierType" />
      <xs:element minOccurs="0" name="NumberOfOptionsNumeric" type="xs:decimal" />
      <xs:element minOccurs="0" maxOccurs="unbounded" name="VSOption2" type="tns:VSOption2Type" />
    </xs:sequence>
  </xs:complexType>

唯一将实现虚拟属性是从几分钟减少项目的编译时间秒。

The only thing adding the dummy attribute achieved was to reduce the compile time of the project from minutes to seconds.

除此之外,VS2008似乎没有注意到的变化 - 我仍然无法序列化对象或没有得到除上面提到的,我丢失或做错了

Other than this, VS2008 didn't seem to notice the changes - I still can't serialise the object or instantiate the service without getting the exception mentioned above, what am I missing or doing wrong?

推荐答案

您必须更改XSD文件在我的问题,但你也必须修改Reference.cs(或.vb)文件相同的文件夹 - 我没有一个找到替换[] [用[](或()()和()在vb.net)。

You have to change the XSD file as in my question, but you ALSO have to modify the Reference.cs (or .vb) file in the same folder - I did a find replace on [][] with [] (or ()() with () in vb.net).

在所有的阅读我所做的,没有答案都表示做两件事,所以我只是忽略了一点 - 我希望这个答案可以帮助别人

In all the reading I've done, no answers have said to do both, so I just missed the point - I hope this answer helps others.

这篇关于我怎样才能正确地修改生成的XSD克服一个已知的.Net错误会导致异常和QUOT; cs0030:无法生成临时类&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆