C# attribute text from resource file?

attributes, c#, resources

Solution

Attribute values are hard-coded into the assembly when you compile. If you want to do anything at execution time, you'll need to use a constant as the key, then put some code into the attribute class itself to load the resource.

Problem

I have an attribute and i want to load text to the attribute from a resource file. ``` [IntegerValidation(1, 70, ErrorMessage = Data.Messages.Speed)] private int i_Speed; ``` But I keep getting "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type" It works perfectly if i add a string instead of Data.Messages.Text, like: ``` [IntegerValidation(1, 70, ErrorMessage = "Invalid max speed")] ``` Any ideas?

Original source