user523650
user523650

Reputation:

Ambiguous references in VS 2010

Trying to upgrade a solution from 2008 to 2010. And I suddenly get a lot of ambiguous reference errors compiling in VS 2010.

It works fine in 2008. Is VS 2010 more strict regarding the using directives?

Upvotes: 3

Views: 5254

Answers (3)

LaGrandMere
LaGrandMere

Reputation: 10359

There is a quite similar post on StackOverFlow : Ambiguous reference error in VS2010

From this article, from Richard :

There may be slight changes in lookup rules about how different cases (e.g. identifier in current namespace takes precedence (as in class Program above).

There are two options to disambiguate:

  1. Use fully qualified identifiers, in the above, either System.Action or ConsoleApplication1.Action.
  2. Use a namespace alias to fully qualify the identifier without so much typing:

    using MyAction = MyNamespace.Action;

Upvotes: 0

k3b
k3b

Reputation: 14755

have you references to two different dll-versions of the same assembly in your solution?

For example are you referencing "System.dll from dotnet 2" plus "System.dll from dotnet 4"?

Upvotes: 2

Luke Duddridge
Luke Duddridge

Reputation: 4347

I had a similar issue.

I dont think it is stricter, but more a coincidences of the newer framework now having the same class name I was using in the dlls referenced, either things were moved or there was some new development to existing dlls.

It took some time to fix the entire project, but the ways around it I found were:

To use either define the full location of the classes

or

define an alias:

using CompanyMagic = Core.Company.Magic;

Upvotes: 4

Related Questions