UtopiaLtd
UtopiaLtd

Reputation: 2590

Nonexistent ambiguous reference

In a Visual Studio 2010 project, we had two identically named classes in two different namespaces that are both commonly included in ViewModels throughout the application. One such class has since been deprecated and removed, but I'm getting an ambiguous reference error when directly referring to the remaining class, even though the old class no longer exists.

We basically have something like this:

using OurNamespace.UI.Common;
using OurNamespace.SomewhereElse;

// *snip*
SomeClass.SomeMethod();

Once upon a time, both of the above namespaces had a SomeClass, but we deleted the one in OurNamespace.UI.Common. However, when building, we get the following error:

'SomeClass' is an ambiguous reference between 'OurNamespace.UI.Common.SomeClass' and 'OurNameSpace.SomewhereElse.SomeClass'

I've already tried cleaning the solution and rebuilding as suggested in answers to this ambigous reference question, only to continue to see the error. What's still lurking behind that makes it think the deleted class still exists for purposes of an ambiguous reference? Even IntelliSense knows there's only one now.

Upvotes: 6

Views: 2627

Answers (3)

jboulter11
jboulter11

Reputation: 152

Super old thread, but in VS2017 I had this happen and had to restart VS to get it fixed after I moved files between namespaces.

Upvotes: 0

Matthew Watson
Matthew Watson

Reputation: 109567

If you look at your project's references (via the References section of the Solution Explorer window), you can right-click the reference and select View in Object Browser.

This allows you to investigate the referenced assemblies to see if the offending class is still lurking in any of them.

Upvotes: 2

phadaphunk
phadaphunk

Reputation: 13313

There's still a reference to the namespace that the old class used to be in (because it has other things in use)

I think your problem is with the reference to the dll that used to contain the deleted class.

Simply remove the reference and re-add it. It should solve the issue.

Upvotes: 0

Related Questions