链接时 IAuthenticationHandler 出现错误 XA2006 [英] error XA2006 with IAuthenticationHandler when linking

查看:37
本文介绍了链接时 IAuthenticationHandler 出现错误 XA2006的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在链接到 SDK 程序集并构建项目时遇到此异常:

I'm encountering this exception when linking to SDK assemblies and building the project:

Java.Interop.Tools.Diagnostics.XamarinAndroidException:错误 XA2006:无法解析对Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler"的引用(在程序集Microsoft.AspNetCore.Http,版本=2.2.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60'),范围为'Microsoft.AspNetCore.Http.Features,Version=2.2.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60'.当作用域与定义的程序集不同时,通常意味着类型被转发.

为了在 Xamarin 中使用 Signalr,我添加了 Signalr.Client v. 3.1.2.

I've added Signalr.Client v. 3.1.2 for using Signalr in Xamarin.

这是 PCL csproj:

Here's the PCL csproj:

<PackageReference Include="Fody" Version="6.1.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Forms.Controls.FlexButton" Version="0.11.0" />
    <PackageReference Include="Microsoft.AppCenter" Version="3.0.0" />
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.0.0" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.0.0" />
    <PackageReference Include="Microsoft.AppCenter.Push" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.2" />
    <PackageReference Include="Plugin.XSnack" Version="1.0.17" />
    <PackageReference Include="PropertyChanged.Fody" Version="3.2.6" />
    <PackageReference Include="Rg.Plugins.Popup" Version="1.2.0.223" />
    <PackageReference Include="sqlite-net-pcl" Version="1.6.292" />
    <PackageReference Include="Xam.Plugin.Media" Version="4.0.1.5" />
    <PackageReference Include="Xamanimation" Version="1.3.0" />
    <PackageReference Include="Xamarin.FFImageLoading" Version="2.4.11.982" />
    <PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
    <PackageReference Include="Xamarin.FFImageLoading.Transformations" Version="2.4.11.982" />
    <PackageReference Include="Xamarin.Forms" Version="4.5.0.356" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.1" />
    <PackageReference Include="Xamarin.Forms.RangeSlider" Version="1.0.2" />
    <PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.5.0.356" />
    <PackageReference Include="XamForms.HtmlLabel" Version="1.0.0" />

这是 Xamarin Android csproj:

and here's the Xamarin Android csproj:

<PackageReference Include="Forms.Controls.FlexButton">
      <Version>0.11.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter">
      <Version>3.0.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter.Analytics">
      <Version>3.0.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter.Crashes">
      <Version>3.0.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter.Push">
      <Version>3.0.0</Version>
    </PackageReference>
    <PackageReference Include="Rg.Plugins.Popup">
      <Version>1.2.0.223</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.Media">
      <Version>4.0.1.5</Version>
    </PackageReference>
    <PackageReference Include="Xamanimation">
      <Version>1.3.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.FFImageLoading">
      <Version>2.4.11.982</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.FFImageLoading.Forms">
      <Version>2.4.11.982</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.FFImageLoading.Transformations">
      <Version>2.4.11.982</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms" Version="4.5.0.356" />
    <PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.1" />
    <PackageReference Include="Xamarin.Forms.RangeSlider">
      <Version>1.0.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms.Visual.Material">
      <Version>4.5.0.356</Version>
    </PackageReference>
    <PackageReference Include="XamForms.HtmlLabel">
      <Version>1.0.0</Version>
    </PackageReference>

project.assets.json 文件对旧版本的 Microsoft.AspNetCore.Http.Features 有两个依赖

The project.assets.json file has two dependencies on older version of Microsoft.AspNetCore.Http.Features

"Microsoft.AspNetCore.Http.Abstractions/2.2.0": {
  "type": "package",
  "dependencies": {
    "Microsoft.AspNetCore.Http.Features": "2.2.0",
    "System.Text.Encodings.Web": "4.5.0"
  },
  "compile": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Http.Abstractions.dll": {}
  },
  "runtime": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Http.Abstractions.dll": {}
  }
},

"Microsoft.AspNetCore.Hosting.Server.Abstractions/2.2.0": {
  "type": "package",
  "dependencies": {
    "Microsoft.AspNetCore.Http.Features": "2.2.0",
    "Microsoft.Extensions.Configuration.Abstractions": "2.2.0"
  },
  "compile": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll": {}
  },
  "runtime": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll": {}
  }
},

其他都是指 3.1.2 版本.

All others refer to 3.1.2 version.

请帮助我确定是否应该使用任何其他版本的软件包,或者对其中任何一个使用跳过链接程序集".

Please help me on whether I should use any other versions of the packages, or maybe using "Skip linking assemblies" with any of them.

谢谢

推荐答案

错误信息

错误 XA2006:无法解析对'Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler'(在程序集 'Microsoft.AspNetCore.Http, Version=2.2.0.0 中定义,文化=中性,PublicKeyToken=adb9793829ddae60') 与范围'Microsoft.AspNetCore.Http.Features, 版本=2.2.0.0,文化=中性,PublicKeyToken=adb9793829ddae60'.

error XA2006: Could not resolve reference to 'Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler' (defined in assembly 'Microsoft.AspNetCore.Http, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') with scope 'Microsoft.AspNetCore.Http.Features, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

以及 project.assets.json 中的条目:

and the entry in the project.assets.json:

"Microsoft.AspNetCore.Http.Abstractions/2.2.0": {
  "type": "package",
  "dependencies": {
    "Microsoft.AspNetCore.Http.Features": "2.2.0",
    "System.Text.Encodings.Web": "4.5.0"
  },
  "compile": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Http.Abstractions.dll": {}
  },
  "runtime": {
    "lib/netstandard2.0/Microsoft.AspNetCore.Http.Abstractions.dll": {}
  }
},

表明您仍然使用旧的 asp.net core 2.2 参考.

shows that you still use an old asp.net core 2.2 reference.

共享项目显示是否被引用:

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />

并将其与 3.1.2 引用混合

and mixing it with 3.1.2 references

<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.2" />

导致您的问题.

在此处删除Microsoft.AspNetCore.Mvc"条目以修复它.

Remove here the "Microsoft.AspNetCore.Mvc" entry to fix it.

这篇关于链接时 IAuthenticationHandler 出现错误 XA2006的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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