Error when calling WithLocalizedMessage
See original GitHub issue- FluentValidation version: 8.1.3
- ASP.NET Core 2.2
I’m getting this error when calling .WithLocalizedMessage(typeof(SharedResource), “Min”):
System.ArgumentException: ‘Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.’
SharedResources is a empty class, with the same name of my resources resx (SharedResource.resx).
Looking at the FluentValidation code, it occurs at LocalizedStringSource.BuildResourceAccessor, in this section (line 74):
var accessor = (Func<string>)property.GetMethod.CreateDelegate(typeof(Func<string>));
I just don’t know what to do.
Thank you guys!
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
Error when calling WithLocalizedMessage · Issue #1058
I'm getting this error when calling .WithLocalizedMessage(typeof(SharedResource), "Min"):. System.ArgumentException: 'Cannot bind to the target ...
Read more >How to pass a value into the error message using fluent ...
The first argument to WithLocalizedMessage must always identify a resource property - you can't place arbitrary code inside there (such as a ...
Read more >Localization — FluentValidation documentation
In its constructor we call the AddTranslation method passing in the language we're using, the name of the validator we want to override,...
Read more >WithLocalizedMessage - FluentValidation Discussions Rss Feed
At the moment, all error messages are passed through a call to string.format (irrespective of whether they came from WithMessage/WithLocalizedMessage). However, ...
Read more >FluentValidation 9.0.0-preview1
A validation library for .NET that uses a fluent interface to construct strongly-typed validation rules.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Added: https://fluentvalidation.net/localization#istringlocalizer I also accept pull requests for the documentation which you’re welcome to contribute to, if you see anything that’s not clear or think should be improved.
Ok if you’re using the automatic registration then they’ll be transient anyway.
Glad it’s working for you now, but feel free to re-open the issue if you are able to reproduce the issue in the future.