The framework I am using is .Net 8
I want to follow these two tutorials to achieve ErrorMessage with different language.Why can't I use resources as ErrorMessage with DataAnnotations?
Blazor WebAssembly Client DataAnnotations Localization
Here is the path of the resources file:
And I have set Access Modifier to public already:
What's more, I have set the resources file path in program.cs also:
builder.Services.AddLocalization(options=>options.ResourcesPath="Resources"); However, when I code it like this:
private sealed class InputModel { [Required(ErrorMessageResourceName = "ErrorMessageUserNameRequire", ErrorMessageResourceType = typeof(SharedResource))] [EmailAddress] public string Email { get; set; } = ""; [Required(ErrorMessageResourceName = "ErrorMessagePasswordRequire", ErrorMessageResourceType = typeof(SharedResource))] [DataType(DataType.Password)] public string Password { get; set; } = ""; [Display(Name = "Remember me?")] public bool RememberMe { get; set; } }Visual Studio reports error:
Severity Code Description Project File Line Suppression State DetailsError CS0246 The type or namespace name 'SharedResource' could not be found (are you missing a using directive or an assembly reference?)What's wrong with my code?
