首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更新VisualStudio2017版本15.8预览后,“无法解析引用:`System.Memory`”或“无法找到`System.Memory`”

更新VisualStudio2017版本15.8预览后,“无法解析引用:`System.Memory`”或“无法找到`System.Memory`”
EN

Stack Overflow用户
提问于 2018-07-12 03:10:37
回答 2查看 11.9K关注 0票数 9

如果这可能对其他人有帮助,我将问并回答这个小问题,在VisualStudio2017版本15.7到版本15.8预览更新之后,这个问题可能会出现在Xamarin.Android和Xamarin.iOS项目中。

演示问题的示例步骤

  1. 创建一个新的空白Xamarin.Android或Xamarin.iOS项目。
  2. 将Microsoft.AspNetCore.SignalR.Client.Core版本1.0.0 NuGet包添加到项目中。
  3. 在项目中使用来自NuGet包的类型。例如,将以下行添加到任何现有方法: var连接=新的Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder().Build();
  4. 对于Xamarin.Android,尝试在Debug配置中构建项目。对于Xamarin.iOS,在iPhone模拟器上构建并运行调试配置中的应用程序。

Visual 2017版本15.7的结果

Xamarin.Android应用程序和Xamarin.iOS应用程序都没有错误地构建和运行。

Visual 2017版15.8预览版的结果

对于Xamarin.Android,构建失败:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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之后会出现这些错误?

EN

回答 2

Stack Overflow用户

发布于 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

https://www.nuget.org/packages/System.Buffers/

票数 8
EN

Stack Overflow用户

发布于 2018-07-12 03:10:37

如何解决这些错误?

要解决这些错误,请在所有使用Microsoft.AspNetCore.SignalR.Client.Core NuGet包的项目中将其更新为1.0.1或更高版本。例如:

  1. 转到工具> NuGet包管理器>管理解决方案的NuGet包>更新
  2. 将Microsoft.AspNetCore.SignalR.Client.Core更新为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或更高版本中。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51296773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档