“Can not resolve reference: `System.Memory`” or “Could not find `System.Memory`” after update to Visual Studio 2017 version 15.8 Preview

前端 未结 2 1240
慢半拍i
慢半拍i 2021-01-12 00:11

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

2条回答
  •  生来不讨喜
    2021-01-12 00:36

    How do I resolve these errors?

    To resolve these errors, update the Microsoft.AspNetCore.SignalR.Client.Core NuGet package to version 1.0.1 or higher in all the projects that use it. For example:

    1. Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution > Updates.

    2. Update Microsoft.AspNetCore.SignalR.Client.Core to version 1.0.1 or higher.

    In Microsoft.AspNetCore.SignalR.Client.Core version 1.0.1, the System.Memory NuGet dependency is now (>= 4.5.1) rather than (>= 4.5.0). And because System.Memory version 4.5.1 no longer includes placeholder files for Xamarin project types, Xamarin projects will now use the .NET Standard 2.0 assembly directly from the NuGet package. This solves the errors because the Xamarin projects can now successfully locate the System.Memory reference.

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

    The errors appeared because the Xamarin SDK versions in Visual Studio 2017 version 15.7 and version 15.8 have a tricky compatibility relationship with the System.Memory NuGet package versions. In Visual Studio 2017 version 15.7, Xamarin.Android and Xamarin.iOS use their own built-in implementations of the types from that NuGet package, so they don't need to reference the assembly from the NuGet package. The System.Memory NuGet package version 4.5.0 accordingly includes placeholder files for Xamarin project types to prevent conflicts.

    But the built-in implementations in the current Xamarin SDK releases do not yet cover the full surface area of the NuGet package. So for Visual Studio 2017 version 15.8, the Mono team temporarily hid those built-in implementations (by switching them to internal and removing the System.Memory facade assembly). This means that Xamarin projects now depend on the implementations from the NuGet package instead. And the System.Memory NuGet package version 4.5.1 accordingly does not include placeholder files for Xamarin project types.

    One more thing to keep in mind is that the built-in implementations in the Xamarin SDKs will cover the full surface area of the NuGet package in a future release. The built-in implementations will then be un-hidden and the placeholder files will be added back to the NuGet package. Users will need to update their NuGet packages once more when that happens. That next change will be coming in Visual Studio 2017 version 15.9 or later.

提交回复
热议问题