InvalidCastException
with System.ComponentModel.DataAnnotations.Validator
(multi-threaded)
#110917
Milestone
InvalidCastException
with System.ComponentModel.DataAnnotations.Validator
(multi-threaded)
#110917
Description
You will occasionally get an
InvalidCastException
when usingValidator
to validate one or moreRangeAttribute
from multiple threads.Reproduction Steps
Expected behavior
Validator members should not throw exceptions when invoked from multiple threads.
Actual behavior
Regression?
No response
Known Workarounds
Validator
.Configuration
Other information
This is likely to occur in applications using Polly - see bug there.
The exception was previously reported as #1143, which simply dismissed thread-safety as a requirement for the attribute instance. Given that attributes are cached at multiple levels by different static components, we need to consider where the best place is to handle this synchronization. If we don't solve it on the attribute level, I would argue that
Validator
should do its own synchronization (or we should be able to create multiple instances ofValidator
for use by multiple threads).The text was updated successfully, but these errors were encountered: