Skip to content

Compiler Error CS0182 while setting ErrorMessage on MinLength Attribute #197

Answered by Sergio0694
robertodalmonte asked this question in Q&A
Discussion options

You must be logged in to vote

This is unrelated from the MVVM Toolkit, the snippet above is just invalid C# syntax. As the docs for the error also state (here), as well as the ECMA spec for the C# language, only compile time constants are allowed as input for attributes. In your case, that Resources.givenName is not a constant, hence the error. You'll have to either make that a constant or come up with some other approach to wire this up (eg. a custom validation attribute taking the property name and then loading with reflection at runtime, or something) 🙂

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robertodalmonte
Comment options

Answer selected by Sergio0694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
not an issue ❌ An issue outside of the scope of the .NET Community Toolkit
2 participants