Xamarin Forms 无法从 nuget 包解析 Azure 存储

Xamarin Forms unable to resolve Azure storage from nuget package

我正在尝试使用共享访问签名将 blob 上传到 Azure。我有令牌并将 nuget 包 WindowsAzure.Storage 添加到我的项目中。我已经尝试了 7.0.0 和 7.0.1 预览版。 出于某种原因,我无法在创建 CloudBlobContainer 实例时解析引用。我也试过只输入 using 语句但没有运气。所有 Azure 文档都指向版本 4.4.0-preview,这是我应该使用的版本吗?

azure 文档参考 https://azure.microsoft.com/da-dk/documentation/articles/storage-xamarin-blob-storage/

此致

我猜文档已经过时了 4.4.0-preview link 而不是 link 到 NuGet 包:

https://www.nuget.org/packages/WindowsAzure.Storage/

CloudBlobContainer 似乎在 Microsoft.WindowsAzure.Storage.Blob 命名空间内。

我会检查以确保您确实安装了 NuGet 包,因为它可能在其他项目中无提示地失败了。

EX: http://screencast.com/t/FLhztkeu

更改 PCL 配置文件对我有用。奇怪。

安装 NuGet 包后,您实际上需要更改 Xamarin 项目上的配置文件。您可以通过转到共享项目 -> 选项 -> 常规 -> C#

  • 将当前配置文件更改为PCL 4.5 – Profile111(我不知道 这是做什么的。)

  • 您现在需要为这个新配置文件重新定位您的 NuGet 包。 右键单击共享项目中的包,你将有 5 这里有选项。

  • 重定向将可用。单击那个。 (这里没有显示,因为我已经 已经重定向)

  • 重建你的项目

我是怎么想出来的

我偶然发现 this Xamarin forum post, where someone had the exact same issue. One user pointed us towards a bug report,其中 PCL 引用不是通过 NuGet 包安装自动添加的。他们建议重新定位,它奏效了!现在我可以包括 using Microsoft.WindowsAzure.Storage.Blob;命名空间。

I have a blog post with more info on this.