3

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?

Ferruccio
  • 98,941
  • 38
  • 226
  • 299
  • 1
    Did you update the project to .Net 4 in your migration? It's probably down to the version of the framework references being used. – Lazarus Jan 06 '11 at 12:41
  • I have tried both! One test witout upgrading .net 4 and one upgrading. Same result on both! –  Jan 06 '11 at 12:43
  • 5
    Can you give us an example of the output showing which classes it is saying are ambiguous? –  Jan 06 '11 at 12:45
  • Not documenting the identifier names is not asking the question the Smart Way. – Hans Passant Jan 06 '11 at 14:25

3 Answers3

4

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;
Luke Duddridge
  • 4,285
  • 35
  • 50
2

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"?

k3b
  • 14,517
  • 7
  • 53
  • 85
0

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;

Community
  • 1
  • 1
LaGrandMere
  • 10,265
  • 1
  • 33
  • 41