如何修复不明确的引用错误?

How to fix ambiguous reference errors?

我有一个允许从 Hotmail、Yahoo 和 GMail 导入联系人的网络应用程序。我终于几乎完成了它,但是由于我添加了 GMail 的导入,我收到了不明确的引用错误,我不确定如何在不破坏任何代码的情况下修复它们。

这是错误的屏幕截图:

你可以试试这样的..

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. 你也可以试试全名space。

    var googleBase = new Google.GData.Client.OAuthBase();
    
  1. 尽可能使用唯一的 class 名称。这将是最终更好的解决方案。
  2. 引用时写入整个命名空间

    OAuth.OAuthBase a = new ...;
    Google.GData.Client.OAuthBase b = new ...;
    
  3. 为其中之一或两者创建 using 别名:

    using n2 = OAuth;
    using      Google.GData.Client;
    
    n2.OAuthBase a = new ...; // referenced using namespace
    OAuthBase b = new ...;    // referenced through existing `using`