Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Why can't find resources namespace in Blazor Web App project?

$
0
0

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:

enter image description here

And I have set Access Modifier to public already:enter image description here

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?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>