【发布时间】:2018-02-10 19:37:59
【问题描述】:
我正在制作一个适用于 Azure IoT 中心的 iOS/Android 应用。据我了解,最新的 Microsoft.Azure.Devices 版本仅与 .Net Standard 项目兼容。我一直在尝试按照这些 twho 教程(1、2)将 PCL 项目转换为 .Net 标准项目但无济于事,而且我对自己做错了什么感到迷茫。
这些是我正在采取的步骤。
- 创建名为 TestProject 的新跨平台应用程序。 Xamarin.Forms -> 空白应用程序 -> 可移植类库 (PCL)
- 右键解决方案 -> 添加新项目 -> .Net Standard -> 创建名为 TestProject.Core 的 .Net 标准库
- 删除自动生成的类 Class1.cs 并将 App.xaml 和 MainPage.xaml 移至 TestProject.Core。
- 删除便携式库TestProject。
- 将 TestProject.Core 重命名为 TestProject。
- 添加 TestProject 对 iOS 和 Android 的引用。
-
点击TestProject并选择Edit TestProject.csproj。将 PropertyGroup 更改为以下:
<PropertyGroup> <TargetFramework>netstandard1.4</TargetFramework> <PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8 </PropertyGroup> 右键单击解决方案并选择管理解决方案的 Nuget 包。
-
勾选Include Prerelease并在TestProject、TestProject.Droid和TestProject.iOS上安装2.3.5.256-pre6 Xamarin.Forms。
李> 清理并重建解决方案。
右键单击 TestProject 并选择管理 Nuget 包。安装Microsft.Azure.Devices
清理并重建。
将代码添加到使用 Microsoft.Azure.Devices 的 TestProject。
-
重建并得到错误:
加载程序集时项目文件行抑制状态错误异常:System.IO.FileNotFoundException: 无法加载程序集“Microsoft.Azure.Devices,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35”。 也许它在 Mono for Android 配置文件中不存在?文件名:“Microsoft.Azure.Devices.dll”
据我所知,我缺少 Microsoft.Azure.Devices Nuget 包 TestProject.Droid,但是,当我尝试安装它时,我收到以下错误:
Could not install package 'System.Threading.Overlapped 4.3.0'.
You are trying to install this package into a project that targets
'MonoAndroid,Version=v7.1', but the package does not contain any assembly references or
content files that are compatible with that framework.
当我尝试在 iOS 上安装 *Microsoft.Azure.Devices** 时:
Could not install package 'System.Threading.Overlapped 4.3.0'. You are trying to install
this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not
contain any assembly references or content files that are compatible with that framework.
【问题讨论】:
标签: c# azure xamarin xamarin.ios xamarin.android