Resolving an Ambiguous Reference

Resolving an ambiguous reference

If the types with the same name exist in both namespaces, you have a couple of options:

1) If the number of types is small, create an alias for that type:

using BorderStyle3d = tool.3dChartLib.BorderStyle;

2) If the number of types is large, you can create an alias for the namespace:

using t3d = tool.3dChartLib;

Then in your code...

t3d.BorderStyle

How to resolve an ambiguous reference caused by a conflicting identifier from inline namespace

Inline namespace scoped variables have static storage duration (internal linking). So declaring

extern int x;

just before displaying x will do it for you
Live on Coliru.
This way, the N1::x won't be considered during name lookup, as it has static storage duration and internal linking.

It's not entirely clear why the code works, so I follow up with a question here.

Ambiguous Reference error between two namespaces

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)

How to resolve incorrect Ambiguous reference from ReSharper on class inheritance?

This is a bug in ReSharper 4.1 and is fixed in one of the later nightly builds.

Download the last nightly build at
http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds.

ambiguous reference

Have you tried right-clicking the solution and doing Clean Solution?

How to fix ambiguous reference errors?

  1. Try to use unique class names as much as possible. This will be the better solution in the end.
  2. Write the entire namespace when referencing

    OAuth.OAuthBase a = new ...;
    Google.GData.Client.OAuthBase b = new ...;
  3. Make an using alias for one or both:

    using n2 = OAuth;
    using Google.GData.Client;

    n2.OAuthBase a = new ...; // referenced using namespace
    OAuthBase b = new ...; // referenced through existing `using`


Related Topics



Leave a reply



Submit