C# IdentityServer4 500内部错误,在使用授权端点时错误使用EpochTimeExtensions

C# IdentityServer4 500内部错误,在使用授权端点时错误使用EpochTimeExtensions,c#,asp.net,identityserver4,C#,Asp.net,Identityserver4,我正在使用ASP.NET为xamarin forms应用程序创建wep api后端, 我正在使用identityserver4进行身份验证和授权。 我想使用授权代码工作流,但在尝试启动授权/身份验证请求时遇到问题 我收到的错误是: System.TypeLoadException:无法从程序集“IdentityModel,版本=4.0.0.0,区域性=中性,PublicKeyToken=e7877f4675df049f”加载类型“IdentityModel.EpochTimeExtensions

我正在使用ASP.NET为xamarin forms应用程序创建wep api后端, 我正在使用identityserver4进行身份验证和授权。 我想使用授权代码工作流,但在尝试启动授权/身份验证请求时遇到问题

我收到的错误是: System.TypeLoadException:无法从程序集“IdentityModel,版本=4.0.0.0,区域性=中性,PublicKeyToken=e7877f4675df049f”加载类型“IdentityModel.EpochTimeExtensions”

我还没有在互联网上找到解决这个问题的方法

这是我的Startup.cs

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }


    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        //services.AddAutoMapper();
        services.AddDbContext<SqlDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
        services.AddScoped<IUnitOfWork, UnitOfWork>();
        services.AddIdentityServer()
            .AddInMemoryIdentityResources(Config.GetResources())
            .AddInMemoryApiResources(Config.GetApis())
            .AddInMemoryClients(Config.GetClients())
            .AddDeveloperSigningCredential();
        services.AddControllers()
            .AddNewtonsoftJson();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        app.UseHttpsRedirection();

        app.UseRouting();

        app.UseIdentityServer();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapGet("/", async context =>
            {
                await context.Response.WriteAsync("Hello World !");
            });
        });
    }
}
公共类启动
{
公共IConfiguration配置{get;}
公共启动(IConfiguration配置)
{
配置=配置;
}
//此方法由运行时调用。请使用此方法将服务添加到容器中。
public void配置服务(IServiceCollection服务)
{
//services.AddAutoMapper();
services.AddDbContext(options=>options.UseSqlServer(Configuration.GetConnectionString(“DefaultConnection”));
services.addScope();
services.AddIdentityServer()
.AddInMemoryIdentityResources(Config.GetResources())
.AddInMemoryApiResources(Config.getAPI())
.AddInMemoryClients(Config.GetClients())
.AddDeveloperSigningCredential();
services.AddControllers()
.AddNewtonsoftJson();
}
//此方法由运行时调用。请使用此方法配置HTTP请求管道。
public void配置(IApplicationBuilder应用程序、IWebHostEnvironment环境)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
其他的
{
//默认的HSTS值为30天。您可能希望在生产场景中更改此值,请参阅https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseIdentityServer();
app.UseEndpoints(端点=>
{
endpoints.MapControllers();
endpoints.MapGet(“/”,异步上下文=>
{
wait context.Response.WriteAsync(“Hello World!”);
});
});
}
}
这是我的config.cs:

public class Config
{
    public static IEnumerable<ApiResource> GetApis()
    {
        return new List<ApiResource>
        {
            new ApiResource("Test", "TestService")
        };
    }

    public static IEnumerable<IdentityResource> GetResources()
    {
        return new List<IdentityResource>
        {
            new IdentityResources.OpenId()
        };
    }

    public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
            new Client
            {
                ClientId = "client",
                AllowedGrantTypes = GrantTypes.Code,
                RequireClientSecret = false,
                RequireConsent = false,
                AllowedScopes = new List<string>{ "Test" , "openid"},
                AllowOfflineAccess = true,
                RedirectUris = new List<String> {
                    "https://localhost:44392/account/test/"
                }
            }
        };
    }
 }
公共类配置
{
公共静态IEnumerable openid&nonce=5&state=5

我希望这里有人能帮助我。
提前感谢

您使用的identity Server 4的哪个版本最新版本,但我也尝试过使用旧版本,但不起作用检查您的identity Model版本是否应>=3.10.6和identity Server版本2.1.2或更高identity Server 4中的identity Model是4.0.0预览版。但我也尝试过安装在不同版本中显式禁用identitymodel,但它仍然不起作用尝试统一安装identityserver4并使用2.1.2进行安装,问题可能是由于4.0.0预览版本、预览版本或取消选中包括预发布您使用的identity server4的最新版本,但我也尝试了旧版本,但它不起作用检查您的identityModel版本它应该是>=3.10.6和identityServer版本2.1.2或更高IdentityServer4中的identityModel是版本4.0.0预览版。但我也尝试在不同版本中显式安装identityModel,但仍然不起作用。尝试统一安装identityServer 4并使用2.1.2安装,可能会出现问题由于4.0.0预览版、预览版或取消选中包含预发行版