【问题标题】:Upgrading projects from .Net 4.6.1 to 4.7.x causes errors in WCF Reference.cs将项目从 .Net 4.6.1 升级到 4.7.x 会导致 WCF Reference.cs 中出现错误
【发布时间】:2019-08-20 07:14:25
【问题描述】:

我有一个使用古老的 ASMX 服务的项目。坐在 .Net Framework 4.6.1 时,我可以添加对服务的引用,我没有遇到任何问题。但是一旦我将项目升级到 4.7 或 4.7.x,我就会开始收到此错误:

'FlightSchedule': member names cannot be the same as their enclosing type

我得到这三种类型。除了代码中的错误之外,如果我尝试删除和添加服务或更新现有服务,则会收到以下警告:

Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='DIAFlightScheduleHttpGet']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='DIAFlightSchedule']/wsdl:port[@name='DIAFlightScheduleHttpGet']
D:\Projects\...\Connected Services\FISAirline\Reference.svcmap  1

Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='DIAFlightScheduleHttpPost']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='DIAFlightSchedule']/wsdl:port[@name='DIAFlightScheduleHttpPost']
D:\Projects\...\Connected Services\FISAirline\Reference.svcmap  1

Custom tool warning: Cannot import wsdl:binding
Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='DIAFlightScheduleHttpGet']
D:\Projects\...\Connected Services\FISAirline\Reference.svcmap  1

Custom tool warning: Cannot import wsdl:binding
Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='DIAFlightScheduleHttpPost']
D:\Projects\...\Connected Services\FISAirline\Reference.svcmap  1

我无法弄清楚这一点。如果我用谷歌搜索警告,有更新 app.config 的指针,但没有协议可供我删除。如果我搜索错误,我找不到任何相关的内容。

我需要更新到最新的框架 v4.8。

非常感谢任何帮助。

【问题讨论】:

    标签: c# wcf asmx


    【解决方案1】:

    您是否尝试过删除服务引用并再次添加服务引用?这种古老的服务称为 XML Web 服务而不是 WCF 服务。该错误通常表明在编译过程中对某些类定义存在模棱两可的理解(类的命名空间问题),这似乎与问题无关。一般来说,XML Web 服务兼容高版本的 DotNet 框架。至少,我无法重现您的问题。
    Xml Web 服务已过时。 BasicHttpBinding 创建的WCF 与传统的soap web 服务很好的兼容。我建议您重新构建您的服务项目。或者,Asp.net WebAPI 可以创建现代 Web 服务,该服务在 Internet 上广泛使用。
    如果有什么我可以帮忙的,请随时告诉我。

    【讨论】:

    • 触摸现有的 API 是不可能的。我也确实删除并添加了该服务。只要我留在 .Net Framework v4.6.1 上或下,客户端就会正确生成。它生成三种与类同名的类型。
    猜你喜欢
    • 2017-09-26
    • 2020-11-16
    • 2023-02-07
    • 2016-10-08
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    相关资源
    最近更新 更多