Reputation: 6152
I'm trying to use the Enterprise Library RangeValidator attribute to validate that a decimal value is greater than zero:
<RangeValidator(GetType(Decimal), "0.00", RangeBoundaryType.Exclusive, "1", RangeBoundaryType.Ignore, "MyMessage", "", Nothing, False, "", "")> _
Public Property Holding() As Decimal
Get
Return _Holding
End Get
Set(ByVal value As Decimal)
_Holding = value
End Set
End Property
However I get the compile error
Overload resolution failed because no accessible 'New' accepts this number of arguments.
As far as I can see I am using the overload correctly. It works fine if I remove the messageTemplate related parameters but I want to be able to specify a custom message.
Has anyone experienced this problem and overcome it?
Upvotes: 2
Views: 2000
Reputation: 22655
You need to specify the messageTemplate as part of the named parameters:
<RangeValidator(GetType(Decimal), "0.00", RangeBoundaryType.Inclusive, "0.00", RangeBoundaryType.Ignore, MessageTemplate := "Value must be greater than 0.")> _
When looking at the documentation, make sure that you are looking at the RangeValidatorAttribute class and not the RangeValidator class.
Upvotes: 4