简体   繁体   English

如何解决含糊的参考错误?

[英]How to fix ambiguous reference errors?

I have a web app that allows importing of contacts from Hotmail, Yahoo and GMail. 我有一个网络应用程序,允许从Hotmail,Yahoo和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. 我终于差不多完成了,但是自从我添加了GMail的导入以来,我得到了模棱两可的参考错误,而且我不确定如何在不破坏任何代码的情况下进行修复。

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别名:

     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(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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