使用框架4.0

时间:2016-03-31 12:05:19

标签: c# .net-4.0 google-drive-api nuget google-api-dotnet-client

几个星期前我正在开发一个项目并打开了Package Manager Console来运行命令Install-Package Google.Apis.Drive.v3。一切似乎都很好,没有任何问题......但是今天当我尝试这样做时,我得到一个错误,告诉我这个软件包不支持Framework 4.0!

PM> Install-Package Google.Apis.Drive.v3
Attempting to resolve dependency 'Google.Apis (≥ 1.11.1)'.
Attempting to resolve dependency 'Google.Apis.Core (≥ 1.11.1)'.
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.10)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.14)'.
Attempting to resolve dependency 'Microsoft.Bcl.Async (≥ 1.0.168)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.2.29)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 7.0.1)'.
Attempting to resolve dependency 'Zlib.Portable.Signed (≥ 1.11.0)'.
Attempting to resolve dependency 'Google.Apis.Auth (≥ 1.11.1)'.
Installing 'Microsoft.Net.Http 2.2.29'.
You are downloading Microsoft.Net.Http from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=329770. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Net.Http 2.2.29'.
Installing 'Newtonsoft.Json 7.0.1'.
Successfully installed 'Newtonsoft.Json 7.0.1'.
Installing 'Google.Apis.Core 1.11.1'.
Successfully installed 'Google.Apis.Core 1.11.1'.
Installing 'Zlib.Portable.Signed 1.11.0'.
You are downloading Zlib.Portable.Signed from AdvancedREI,  onovotny, the license agreement to which is available at http://en.wikipedia.org/wiki/Zlib_License. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Zlib.Portable.Signed 1.11.0'.
Installing 'Google.Apis 1.11.1'.
Successfully installed 'Google.Apis 1.11.1'.
Installing 'Google.Apis.Auth 1.11.1'.
Successfully installed 'Google.Apis.Auth 1.11.1'.
Installing 'Google.Apis.Drive.v3 1.11.1.434'.
Successfully installed 'Google.Apis.Drive.v3 1.11.1.434'.
Adding 'Microsoft.Net.Http 2.2.29' to Drilyser.
Successfully added 'Microsoft.Net.Http 2.2.29' to Drilyser.
Adding 'Newtonsoft.Json 7.0.1' to Drilyser.
Successfully added 'Newtonsoft.Json 7.0.1' to Drilyser.
Adding 'Google.Apis.Core 1.11.1' to Drilyser.
Uninstalling 'Google.Apis.Core 1.11.1'.
Successfully uninstalled 'Google.Apis.Core 1.11.1'.
Uninstalling 'Newtonsoft.Json 7.0.1'.
Successfully uninstalled 'Newtonsoft.Json 7.0.1'.
Uninstalling 'Microsoft.Net.Http 2.2.29'.
Successfully uninstalled 'Microsoft.Net.Http 2.2.29'.
Install failed. Rolling back...
Install-Package : Could not install package 'Google.Apis.Core 1.11.1'. You are trying t
o install this package into a project that targets '.NETFramework,Version=v4.0', but th
e package does not contain any assembly references or content files that are compatible
 with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<<  Google.Apis.Drive.v3
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationExc 
   eption
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands. 
   InstallPackageCommand

我在VS2010中开发并使用Framework 4.0。所以我需要在我的环境中安装此软件包。他们是否可以在最近几周内发布的版本中将软件包更改为仅支持4.5+?我有什么想法可以解决这个问题吗?

我的目标是访问Google云端硬盘API,并能够关注位于here的示例。

3 个答案:

答案 0 :(得分:3)

请参阅:https://www.nuget.org/packages/Google.Apis/。支持的平台指定为.Net Framework 4.5

Drive API.v3的最新版本仅支持.Net Framework 4.5

如果您确实需要在.Net Framework 4.0中使用它,那么我建议您安装以前版本的软件包。
Google.Apis.Drive.v3 Client Library 1.10.0.130似乎同时支持.Net 4.0.Net 4.5

使用此命令安装此特定版本

Install-Package Google.Apis.Drive.v3 -Version 1.10.0.130

如果此版本不起作用,请尝试以前的版本。希望这会有所帮助。

答案 1 :(得分:2)

截至2016年3月22日,已终止对.Net Framework 4.0的Google .Net客户端库支持的发布v1.11(请参阅#696)。

Nuget Get软件包目前存在一个问题,即尝试在.Net 4.0项目上安装它们应该下载旧的不再支持或开发的软件包。它无法正常工作将自己下载以前的v1.10版本。 (Link

或者您可以将项目升级到.net framework 4.5并使用库的受支持部分。

<强>更新

如果您选择继续使用库的.Net 4.0版本,请注意不会有进一步的更新。这不仅存在于核心库中,还存在于所有生成的API库中。如果您使用的API发布或更改任何内容,您将无法获得任何这些更改。

#FFF

答案 2 :(得分:0)

我认为你在谈论这个软件包:Google.Apis.drive.v3正如你所看到的,它支持以下平台:

**Supported Platforms:**
 - .NET Framework 4.5
 - Windows Store apps
 - Windows Phone 8 and 8.1
 - Portable Class Libraries

因此它不支持4.0,请升级它。