两个名称空间之间的引用错误 [英] Ambiguous Reference error between two namespaces
问题描述
我在尝试在浏览器上运行Web服务时收到此消息.请注意,源代码是Windows文件,无法根据我的需要进行更改.
I get this message while trying to run a webservice on the browser. Note that the source code is a windows file and can't be changed for my need.
编译器错误消息:CS0104:'消息'是一个不明确的引用在"ThreeDSeekUtils.Message"和'System.Web.Services.Description.Message'
Compiler Error Message: CS0104: 'Message' is an ambiguous reference between 'ThreeDSeekUtils.Message' and 'System.Web.Services.Description.Message'
源错误:
第263行:void WriteSoapMessage(MessageBinding messageBinding,留言留言,bool soap12){objectId = 0;SoapOperationBinding soapBinding;
Line 263: void WriteSoapMessage(MessageBinding messageBinding, Message message, bool soap12) { objectId = 0; SoapOperationBinding soapBinding;
源文件:c:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config \ DefaultWsdlHelpGenerator.aspx
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\DefaultWsdlHelpGenerator.aspx
如何解决此问题而不从我的Web服务中删除ThreeDSeekUtils和System.Web.Services的命名空间?(我的网络服务-Service1.asmx中都需要这些)之前没有回答过这个问题.
How can I go about resolving this without removing the namespaces of ThreeDSeekUtils and System.Web.Services from my Webservice? (I need both these in my webservice - Service1.asmx) This question wasn't answered before.
推荐答案
您需要调整签名以指定 Message
类的显式命名空间:
You need to adjust the signature to specify the explicit namespace of the Message
class:
void WriteSoapMessage(MessageBinding messageBinding,
ThreeDSeekUtils.Message message, bool soap12)
或
void WriteSoapMessage(MessageBinding messageBinding,
System.Web.Services.Description.Message message, bool soap12)
以适当者为准.另一个选择是在类顶部的 using
块中为您的命名空间添加别名:
Whichever is appropriate. Another option is to alias your namespaces in the using
block at the top of the class:
using ThreeD = ThreeDSeekUtils;
using ServicesDesc = System.Web.Services.Description;
然后,您可以以较短的形式使用别名:
Then you could use the aliases in shorter form:
void WriteSoapMessage(MessageBinding messageBinding,
ThreeD.Message message, bool soap12)
或
void WriteSoapMessage(MessageBinding messageBinding,
ServicesDesc.Message message, bool soap12)
这篇关于两个名称空间之间的引用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!