首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >IdentityModel中断“无法加载文件或程序集'System.Numerics.Vectors,Version=4.1.4.0”

IdentityModel中断“无法加载文件或程序集'System.Numerics.Vectors,Version=4.1.4.0”
EN

Stack Overflow用户
提问于 2022-05-04 13:13:15
回答 1查看 293关注 0票数 0

我们有一个.NET框架4.7.1项目

我在IdentityModel软件包管理器中安装了NuGet 6.0.0。它为我安装了以下依赖项:

代码语言:javascript
运行
复制
Microsoft.Bcl.AsyncInterfaces 6.0.0
System.Buffers 4.5.1
System.Memory 4.5.4
System.Numerics.Vectors 4.5.0
System.Text.Json 6.0.3
System.ValueTuple 4.5.0

我试图运行以下代码来查看服务是否存在:

代码语言:javascript
运行
复制
var disco = await clientAuth.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest
{
    Address = server,
    Policy =
    {
        ValidateIssuerName = false
    }
});
if (disco.IsError) {...}

但是,它不断地产生错误。我设法深入研究了代码,最后发现如下: var result = System.Text.Json.JsonDocument.Parse("{"issuer":"https:....}").RootElement;

我得出的错误是:

代码语言:javascript
运行
复制
Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

at System.Text.Json.JsonReaderHelper.IndexOfOrLessThan(Byte& searchSpace, Byte value0, Byte value1, Byte lessThan, Int32 length) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs:line 208

at System.Text.Json.Utf8JsonReader.ConsumeString() in /_/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs:line 1276

at System.Text.Json.Utf8JsonReader.ConsumePropertyName() in /_/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs:line 1227

at System.Text.Json.Utf8JsonReader.ReadSingleSegment() in /_/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs:line 852

at System.Text.Json.Utf8JsonReader.Read() in /_/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs:line 272

at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs:line 1092

at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.Parse.cs:line 697

at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 json, JsonDocumentOptions options) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.Parse.cs:line 271

at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.Parse.cs:line 316

at Citadel.Framework.APICalls.APIBase.<Setup>d__3.MoveNext() in C:\Dev\Src\Tyrus\Production\Tyrus_5_1\Citadel.Framework.APICalls\APIBase.cs:line 86

我设法钻研了ConsumeString方法,但什么也学不到。

最烦人的是我无法为System.Numerics.Vectors加载4.1.4版本

在Nuget Manager中,只有以下版本可用:

代码语言:javascript
运行
复制
4.5.0 - current
4.4.0
4.3.0
4.1.1
4.1.0
4.0.0

在这个特定的问题上,我在互联网上得到的很少,我已经尝试了我所能找到的任何没有任何运气的东西。我试过清理我的nuget缓存。我不记得我已经删除和读取依赖项多少次了,我已经清理了我的解决方案并重新构建了它。我尝试了以下几种组合:

代码语言:javascript
运行
复制
<dependentAssembly>
    <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.1.4.0" />
</dependentAssembly>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-04 18:32:27

原来,在根项目文件中添加以下行将神奇地使所有问题消失:

代码语言:javascript
运行
复制
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

奇怪的是,我没有发现任何文章暗示这一点。

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

https://stackoverflow.com/questions/72113569

复制
相关文章

相似问题

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