如果它可以帮助其他任何人,我会询问并回答这个小问题,该问题可以在从Visual Studio 2017版本15.7更新到15.8版预览版之后出现在Xamarin.Android和Xamarin.iOS项目中.
使用项目中NuGet包中的类型.例如,将以下行添加到任何现有方法:
var connection = new Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder().Build();
Run Code Online (Sandbox Code Playgroud)对于Xamarin.Android,尝试在Debug配置中构建项目.对于Xamarin.iOS,在iPhone模拟器上的Debug配置中构建并运行应用程序.
Xamarin.Android应用程序和Xamarin.iOS应用程序都可以无错误地构建和运行.
对于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: …Run Code Online (Sandbox Code Playgroud)