2016-01-05 69 views
-1

我发现了一个很短的工作实例获得与谷歌联系人API这里联系人:http://www.daimto.com/google-contacts-with-c/,但是当我试图把它翻译到VB网,我有以下错误:问题从C#转换到VB网

BC30652 a reference to assembly 'Google.Apis.Core, Version = 1.8.1.31685, Culture = neutral, PublicKeyToken = null' containing the type 'IDataStore' is required. Add it to the project

这是给我的错误只有一部分:

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret } 
                       , scopes 
                       , "test" 
                       , CancellationToken.None 
                       , new FileDataStore("test")).Result; 

在VB中网,我有:

Dim credential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With { 
      .ClientId = clientId, 
      .ClientSecret = clientSecret 
     }, scopes, "test", CancellationToken.None, New FileDataStore("test")).Result 

错误从GoogleWebAuthorizationBroker出现。任何人都可以帮助我正确翻译?

+3

您是否添加了程序集参考? –

+1

当你看到错误时,你做了什么?你读过它吗? –

+0

该问题与转换问题无关。只需要在组件中添加一个DLL即可。也许这个话题应该被重新渲染。 – etalon11

回答

2

由于它是指定的in your link,您应该从here或直接使用nuget visual studio extension安装它。

Nuget将安装所有依赖项。在你的情况下,它的效果是Google Api Core

其实这与C#到VB转换无关。这只是一个缺失的参考。

+0

That''s这件事,我已经安装了谷歌API的核心,我必须resinstall它? – user3822492

+0

@ user3822492是的。有些东西可能出错了,因为参考文献(与提及的版本)不被视为现在。它可能来自引用的版本和预期的版本之间的不匹配。你可以检查组件版本化的方式。 https://msdn.microsoft.com/en-us/library/51ket42z%28v=vs.110%29.aspx。 – Fab

0

我找到了解决方案: *当我试图卸载Google.Apis.Core时,它显示我无法卸载,因为Google.Apis.Auth取决于它。 *当我试图卸载Google.Apis.Auth时,它显示我无法卸载,因为Google.Apis.DriveV2取决于它。 *当我试图卸载Google.Apis.Drive.v2时,我看到它能够进行更新,然后我更新了Google.Apis.Drive.v2,然后一切正常! 我希望这篇文章能够帮助任何有此问题的人,并感谢所有的帮助。