Search code examples
c#asp.net.netwebformsambiguous

How to fix ambiguous reference errors?


I have a web app that allows importing of contacts from Hotmail, Yahoo and GMail. I finally have it almost completed but since I added the importing of GMail, I am getting ambiguous reference errors and I am unsure how to fix them without breaking any code.

Here is a screen shot of the errors:

Ambiguous Reference Errors


Solution

    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`