question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Mar 26, 2019

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.

0reactions
JeremySkinnercommented, Mar 26, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found