“无法解析引用:`System.Memory`";或“找不到‘System.Memory’";更新到 Visual Studio 2017 版本 15.8 预览版后 [英] "Can not resolve reference: `System.Memory`" or "Could not find `System.Memory`" after update to Visual Studio 2017 version 15.8 Preview

查看:69
本文介绍了“无法解析引用:`System.Memory`";或“找不到‘System.Memory’";更新到 Visual Studio 2017 版本 15.8 预览版后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果它可能对其他人有帮助,我将询问并回答这个关于 Xamarin.Android 和 Xamarin.iOS 项目在从 Visual Studio 2017 版本 15.7 更新到版本 15.8 预览版后可能出现的问题的小问题.

In case it might help anyone else, I'll ask and answer this little question about an issue that can appear in Xamarin.Android and Xamarin.iOS projects after an update from Visual Studio 2017 version 15.7 to version 15.8 Preview.

  1. 创建一个新的空白 Xamarin.Android 或 Xamarin.iOS 项目.
  2. 将 Microsoft.AspNetCore.SignalR.Client.Core 版本 1.0.0 NuGet 包添加到项目中.
  3. 在项目中使用 NuGet 包中的类型.例如,将以下行添加到任何现有方法中:

  1. Create a new blank Xamarin.Android or Xamarin.iOS project.
  2. Add the Microsoft.AspNetCore.SignalR.Client.Core version 1.0.0 NuGet package to the project.
  3. Use a type from the NuGet package in the project. For example, add the following line to any existing method:

var connection = new Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder().Build();

  • 对于 Xamarin.Android,尝试在调试配置中生成项目.对于 Xamarin.iOS,在 iPhone 模拟器上的调试配置中生成并运行应用.

  • For Xamarin.Android, attempt to build the project in the Debug configuration. For Xamarin.iOS, build and run the app in the Debug configuration on iPhone simulator.

    Visual Studio 2017 版本 15.7 的结果

    Xamarin.Android 应用和 Xamarin.iOS 应用的构建和运行都没有错误.

    Results with Visual Studio 2017 version 15.7

    Both the Xamarin.Android app and the Xamarin.iOS app build and run without error.

    对于 Xamarin.Android,构建失败:

    For Xamarin.Android, the build fails:

    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:

    For Xamarin.iOS, the app launches successfully on the simulator, but the debug output shows that the app fails to find System.Memory when it's running:

    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 后会出现这些错误?

    How do I resolve these errors? As a follow-up, why did these errors appear after I updated Visual Studio?

    推荐答案

    我使用的是 VS Entreprise 2017 Version 15.9.1

    I use VS Entreprise 2017 Version 15.9.1

    解决我面临的问题(无法解决引用:System.Buffers,由System.Memory引用.请为添加NuGet包或程序集引用>System.Buffers,或删除对 System.Memory 的引用.),我只是通过这个命令安装 System.Buffers 包:

    To solve the problem I face ( Can not resolve reference: System.Buffers, referenced by System.Memory. Please add a NuGet package or assembly reference for System.Buffers, or remove the reference to System.Memory.), I just install System.Buffers package by this command:

    安装包 System.Buffers -版本 4.5.0

    Install-Package System.Buffers -Version 4.5.0

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

    这篇关于“无法解析引用:`System.Memory`";或“找不到‘System.Memory’";更新到 Visual Studio 2017 版本 15.8 预览版后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆