FluentValidation: Error when calling WithLocalizedMessage
- 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!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (11 by maintainers)
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.