我正在尝试使用 PCLStorage
从 PCL
项目获取文件,如下所示。我在 Visual Studio 2015 Professional 中使用 Xamarin。
IFile file = await FileSystem.Current.GetFileFromPathAsync("file\path");
但是我遇到了异常:
System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation.
最佳答案
您需要将 PCLStorage NuGet 添加到您的 PCL 和平台特定项目中。
所以如果你有以下解决方案:
PCL
Android
iOS
您需要将它添加到所有这些:
PCL
PCLStorage
Android
PCLStorage
iOS
PCLStorage
为什么?因为 NuGet 使用诱饵和开关技术,其中 PCL 包含带有诱饵的简单外观。在运行时,这会被特定于平台的实现切换。
关于.net - 尝试使用 PCL 项目中的 PCLStorage 读取文件时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39998440/