The_Inquisitive
The_Inquisitive

Reputation: 33

Ambiguous Reference error between two namespaces

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:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\DefaultWsdlHelpGenerator.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.

Upvotes: 2

Views: 9481

Answers (3)

Haney
Haney

Reputation: 34852

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)

Upvotes: 4

Zeus82
Zeus82

Reputation: 6375

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();

Upvotes: 1

Dalorzo
Dalorzo

Reputation: 20014

One simple solution is to write your methods with the full namespace like:

void WriteSoapMessage(MessageBinding messageBinding, ThreeDSeekUtils.Message message, bool soap12)

Upvotes: 1

Related Questions