IdentityModel与“无法加载文件或汇编” System.Numerics.Vectors,版本= 4.1.4.0;

发布于 2025-01-26 03:05:34 字数 3147 浏览 1 评论 0原文

我们有一个.NET Framework 4.7.1项目

我使用Nuget软件包管理器安装了IdentityModel 6.0.0。它为我安装了以下依赖关系:

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

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

var disco = await clientAuth.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest
{
    Address = server,
    Policy =
    {
        ValidateIssuerName = false
    }
});
if (disco.IsError) {...}

但是,它不断生成错误。我设法深入探讨了该法规,最后遇到了这一点: https:....}”)。

“ {“ issuer”: “

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

var result = system.text.json.jsondocument.parse ( 都没学

什么

但是

4.5.0 - current
4.4.0
4.3.0
4.1.1
4.1.0
4.0.0

。这个特定的问题,我尝试了所有可以找到的一切。重建它。

<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>

We have a .NET Framework 4.7.1 project

I installed IdentityModel 6.0.0 with the NuGet Package Manager. It installed the following dependencies for me:

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

I'm trying to run the following code to see if a service exists:

var disco = await clientAuth.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest
{
    Address = server,
    Policy =
    {
        ValidateIssuerName = false
    }
});
if (disco.IsError) {...}

But, it keeps generating an error. I managed to drill down into the code, and finally came upon this:
var result = System.Text.Json.JsonDocument.Parse("{"issuer":"https:....}").RootElement;

The error I get on this is:

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

I managed to drill down to the ConsumeString method, but couldn't learn anything.

The most annoying of all is I can't load version 4.1.4 for System.Numerics.Vectors

In the Nuget Manager, only the following versions are available:

4.5.0 - current
4.4.0
4.3.0
4.1.1
4.1.0
4.0.0

I'm getting preciously little on the internet regarding this specific issue, and I've tried everything I could find without any luck. I've tried clearing my nuget cache. I can't remember how many times I've removed and readded the dependencies, I've cleaned my solution and rebuild it. I tried a number of combinations of:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尘世孤行 2025-02-02 03:05:34

如果将v4.5.0安装在system.numerics.vectors的v4.5.0到您的GAC,则它会自动安装在汇编缓存中的v4.1.4路径中。如果已安装了一个system.numerics.vectors v4.5.0的项目。代码>。

If you install v4.5.0 of System.Numerics.Vectors to your GAC, it automatically installs into the path for v4.1.4 in the assembly cache. If you have a project where System.Numerics.Vectors v4.5.0 is installed, navigate to the net46 path for the DLL and from elevated Visual Studio Developer Command Prompt, type gacutil -i System.Numerics.Vectors.dll.

无力看清 2025-02-02 03:05:34

事实证明,在root项目文件中添加以下行会神奇地使所有问题消失:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

奇怪的是,我没有找到任何建议的文章。

Turns out that adding the following line in your root project file will magically make all the problems go away:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

Odd that I didn't find any article suggesting this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文