如果这可能对其他人有帮助,我将问并回答这个小问题,在VisualStudio2017版本15.7到版本15.8预览更新之后,这个问题可能会出现在Xamarin.Android和Xamarin.iOS项目中。
演示问题的示例步骤
Visual 2017版本15.7的结果
Xamarin.Android应用程序和Xamarin.iOS应用程序都没有错误地构建和运行。
Visual 2017版15.8预览版的结果
对于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之后会出现这些错误?
发布于 2018-11-16 11:49:43
我使用VS Entreprise2017版本15.9.1
为了解决我面临的问题(不能解决引用:System.Buffers,由System.Memory引用)。请为NuGet添加一个System.Buffers包或程序集引用,或者删除对System.Memory的引用。),我只需通过以下命令安装System.Buffers包:
安装-软件包System.Buffers -Version 4.5.0
发布于 2018-07-12 03:10:37
如何解决这些错误?
要解决这些错误,请在所有使用Microsoft.AspNetCore.SignalR.Client.Core NuGet包的项目中将其更新为1.0.1或更高版本。例如:
在Microsoft.AspNetCore.SignalR.Client.Core版本1.0.1中,System.Memory NuGet依赖项现在是(>= 4.5.1)而不是(>= 4.5.0)。由于System.Memory版本4.5.1 不再包括Xamarin项目类型的占位符文件。,Xamarin项目现在将直接从NuGet包中使用.NET标准2.0程序集。这解决了错误,因为Xamarin项目现在可以成功地定位System.Memory引用。
作为后续,为什么在我更新Visual之后会出现这些错误?
出现这些错误是因为VisualStudio2017版本15.7和版本15.8中的Xamarin版本与System.Memory NuGet包版本有着复杂的兼容性关系。在VisualStudio2017版本15.7中,Xamarin.Android和Xamarin.iOS使用来自该NuGet包的类型的内置实现,因此它们不需要引用NuGet包中的程序集。因此,System.Memory NuGet包版本4.5.0包含Xamarin项目类型的占位符文件,以防止冲突。
但是,目前Xamarin版本中的内置实现还没有涵盖NuGet包的全部表面积。因此,对于VisualStudio2017版本15.8,Mono团队暂时隐藏了那些内置实现(由internal和删除System.Memory外观程序集实现)。这意味着Xamarin项目现在依赖于来自NuGet包的实现。因此,System.Memory NuGet包版本4.5.1不包括Xamarin项目类型的占位符文件。
需要记住的另一件事是,Xamarin中的内置实现将在未来的版本中涵盖NuGet包的全部表面积。然后,内置实现将被取消隐藏,占位符文件将被添加回NuGet包。当发生这种情况时,用户将需要再次更新他们的NuGet包。下一个更改将出现在VisualStudio2017版本15.9或更高版本中。
https://stackoverflow.com/questions/51296773
复制相似问题