简体   繁体   中英

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:

含糊的参考错误

  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` 

you can try something like this..

using GoogleOAuthBase = Google.GData.Client.OAuthBase;

namespace abc
{


    public class Program
    {        
           //make sure this Google.GData.Client.OAuthBase is instansiateable
           var googleBase = new GoogleOAuthBase();
     }
}
  1. you can try entire name space as well.

     var googleBase = new Google.GData.Client.OAuthBase(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM