gpt4 book ai didi

c# - System.MissingMethodException : Method not found: 'Void Microsoft. AspNetCore.Identity.DataProtectorTokenProvider

转载 作者:行者123 更新时间:2023-12-03 14:48:16 26 4
gpt4 key购买 nike

仍然在我遇到问题的同一个项目 DI Registration service type .net core 3.0 .现在当这个问题被修复时,我收到了新的错误。
现在我的代码看起来:

    services.AddDbContext<ApplicationIdentityDbContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("Default")));

services.AddIdentityCore<ApplicationUser>(options =>
{
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequiredLength = 4;

options.SignIn.RequireConfirmedEmail = true;
options.Tokens.ProviderMap.Add("CustomEmailConfirmation",
new TokenProviderDescriptor(
typeof(CustomEmailConfirmationTokenProvider<IdentityUser>)));

options.Tokens.EmailConfirmationTokenProvider = "CustomEmailConfirmation";

})
.AddEntityFrameworkStores<ApplicationIdentityDbContext>();

services.AddTransient(o =>
{
var service = new CustomEmailConfirmationTokenProvider<IdentityUser>(o.GetService<IDataProtectionProvider>(), o.GetService<IOptions<DataProtectionTokenProviderOptions>>(), o.GetService<ILogger<DataProtectorTokenProvider<IdentityUser>>>());

return service;
});

错误是:

System.MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.Identity.DataProtectorTokenProvider1..ctor(Microsoft.AspNetCore.DataProtection.IDataProtectionProvider,
Microsoft.Extensions.Options.IOptions
1)'.

最佳答案

我遇到了同样的问题,问题与包本身有关。

基本上问题在于其中许多 Microsoft.AspNetCore.*软件包现在移至 Microsoft.AspNetCore.App框架,所以你删除你的 Microsoft.AspNetCore.Identity引用并将其添加到您的项目中:

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

我注意到我的构造函数(和你的一样)缺少附加参数 ILogger<DataProtectorTokenProvider<TUser>> ,您可以在此 link. 上的 .NET Core 3.* 版本中看到

关于c# - System.MissingMethodException : Method not found: 'Void Microsoft. AspNetCore.Identity.DataProtectorTokenProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58973703/

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