gpt4 book ai didi

c# - Auth0 LoginResult 无法加载 Newtonsoft.Json 10.0.0.0

转载 作者:行者123 更新时间:2023-11-30 17:29:14 27 4
gpt4 key购买 nike

我在尝试使用 Auth0.OidcclientWpf SDK 实现 LoginAsync 时遇到了一种奇怪的情况。我正在使用以下代码:

private async void PerformAuthenticationAsync()
{
Auth0Client auth0Client = new Auth0Client(new Auth0ClientOptions()
{
Domain = "mydomain",
ClientId = "clientid"
});

var extraParameters = new Dictionary<string, string>();
extraParameters.Add("connection", "connectionParam");
var result = await auth0Client.LoginAsync(extraParameters: extraParameters);
}

执行身份验证过程后,出现错误:

Not able to load NewtonSoftJson.dll version - 10.0.0.0

来源是 Identitymodel.oidclient。在将 IdentityModelEventSource.ShowPII 设置为 True 后,我可以在跟踪中看到我正在寻找的 token 已收到,但 LoginResult 失败解码 header 。

我尝试在我的项目中引用 NewtonSoft.Json dll 版本 10.0.2。现在我遇到异常:

Not able to load NewtonSoftJson.dll version 11.0.0.0

这次甚至没有启动浏览器来输入凭据。

我很困惑我应该引用哪个版本的 NewtonSoft.Json dll?我将 IdentityModel.oidcclient 更新到最新版本。即使在那之后,IdentityModel.Oidcclient.LoginResult 仍在提示 NewtonSoft.Json 版本 10.0.0.0 不可用。

我不确定真正的问题是什么。我是否必须同时引用这两个版本(10 和 11)以及如何做到这一点?如果有人可以提供帮助,我将不胜感激。

更新

下面是我得到的痕迹-

System.TypeInitializationException: The type initializer for 'System.IdentityModel.Tokens.Jwt.JsonExtensions' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.IdentityModel.Tokens.Jwt.JsonExtensions..cctor() --- End of inner exception stack trace --- at System.IdentityModel.Tokens.Jwt.JsonExtensions.DeserializeJwtHeader(String jsonString) at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData) --- End of inner exception stack trace --- at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ReadJwtToken(String token) at IdentityModel.OidcClient.IdentityTokenValidator.d__4.MoveNext() >

最佳答案

同样的问题,Auth0.OidcClient 2.2.0.0 和 Newtonsoft.Json 版本 11.0.0.0。

我也没有真正解决这个问题的方法。最后,我实现了一个自定义程序集解析处理程序作为解决方法。

为确保这不会影响应用程序的其余部分,我只是在登录窗口打开时临时安装处理程序。我还确保只加载名为“Newtonsoft.Json”的程序集。处理程序在执行程序集的文件夹中查找 Newtonsoft.Json 程序集。

关于c# - Auth0 LoginResult 无法加载 Newtonsoft.Json 10.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51434945/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com