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.
Compiler Error Message: CS0104: ‘Message’ is an ambiguous reference
between ‘ThreeDSeekUtils.Message’ and
‘System.Web.Services.Description.Message’Source Error:
Line 263: void WriteSoapMessage(MessageBinding messageBinding,
Message message, bool soap12) {
objectId = 0; SoapOperationBinding soapBinding;Source File:
c:WindowsMicrosoft.NETFrameworkv4.0.30319ConfigDefaultWsdlHelpGenerator.aspx
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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You need to adjust the signature to specify the explicit namespace of the Message class:
void WriteSoapMessage(MessageBinding messageBinding,
ThreeDSeekUtils.Message message, bool soap12)
or
void WriteSoapMessage(MessageBinding messageBinding,
System.Web.Services.Description.Message message, bool soap12)
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)
or
void WriteSoapMessage(MessageBinding messageBinding,
ServicesDesc.Message message, bool soap12)
Method 2
One simple solution is to write your methods with the full namespace like:
void WriteSoapMessage(MessageBinding messageBinding, ThreeDSeekUtils.Message message, bool soap12)
Method 3
You can fully qualify the class name when you declare your variable.
Don’t do
Message msg = new Message();
Do:
ThreeDSeekUtils.Message msg = new ThreeDSeekUtils.Message();
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0