【发布时间】:2018-07-12 03:10:37
【问题描述】:
如果它可能对其他人有所帮助,我将就从 Visual Studio 2017 版本 15.7 更新到版本 15.8 预览后可能出现在 Xamarin.Android 和 Xamarin.iOS 项目中的问题提出并回答这个小问题。
演示问题的示例步骤
- 创建一个新的空白 Xamarin.Android 或 Xamarin.iOS 项目。
- 将 Microsoft.AspNetCore.SignalR.Client.Core 版本 1.0.0 NuGet 包添加到项目中。
-
在项目中使用 NuGet 包中的类型。例如,将以下行添加到任何现有方法中:
var connection = new Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder().Build(); 对于 Xamarin.Android,尝试在调试配置中构建项目。对于 Xamarin.iOS,在 iPhone 模拟器上的调试配置中构建并运行应用程序。
Visual Studio 2017 版本 15.7 的结果
Xamarin.Android 应用和 Xamarin.iOS 应用都生成并运行无错误。
Visual Studio 2017 版本 15.8 Preview 4 的结果
对于 Xamarin.Android,构建失败:
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.Connections.Abstractions`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.Connections.Abstractions`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Client.Core`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Client.Core`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Common`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Common`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Protocols.Json`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Protocols.Json`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.Extensions.Primitives`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.Extensions.Primitives`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `System.IO.Pipelines`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `System.IO.Pipelines`.
对于 Xamarin.iOS,应用在模拟器上成功启动,但调试输出显示应用在运行时找不到 System.Memory:
Could not find `System.Memory` referenced by assembly `System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Client.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.Extensions.Primitives, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.Connections.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Protocols.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
如何解决这些错误?追问一下,为什么我更新Visual Studio后会出现这些错误?
【问题讨论】:
标签: xamarin xamarin.ios xamarin.android