Subclassing and validation rulesSubclassing and validation rules
Old forum URL: forums.lhotka.net/forums/t/1856.aspx
mr_lasseter posted on Tuesday, November 28, 2006
I have subclassed the BusinessBase and am having problems with the validation rules in a class that inherits from the subclassed BusinessBase. My code is below.
MyBusinessBase:
Public MustInherit Class MyBusinessBase(Of T As MyBusinessBase(Of T)) : Inherits Csla.BusinessBase(Of T)
Class that inherits MyBusinessBase
Public Class MyClass : Inherits MyBusinessBase(Of MyClass)
Protected Overrides Sub AddBusinessRules()
Me.ValidationRules.AddRule(AddressOf Validation.CommonRules.StringRequired, "MyString")
End Sub
End Class
The comliper is giving me an error on the line where I add the validation rule (I am using Csla 2.1).
The error is
"Overload resolution failed because no accessible 'AddRule' can be called with these arguments:
'Public Sub AddRule(Of T, R As Csla.Validation.RuleArgs)(handler As Csla.Validation.RuleHandler(Of T, R), args As R)': Type parameter 'T' for 'Public Sub AddRule(Of T, R As Csla.Validation.RuleArgs)(handler As Csla.Validation.RuleHandler(Of T, R), args As R)' cannot be inferred.
'Public Sub AddRule(handler As Csla.Validation.RuleHandler, args As Csla.Validation.RuleArgs)': Method 'Public Function StringRequired(target As Object, e As Csla.Validation.RuleArgs) As Boolean' does not have the same signature as delegate 'Delegate Function RuleHandler(target As Object, e As Csla.Validation.RuleArgs) As Boolean'.
'Public Sub AddRule(handler As Csla.Validation.RuleHandler, args As Csla.Validation.RuleArgs)': Value of type 'String' cannot be converted to 'Csla.Validation.RuleArgs'.
'Public Sub AddRule(Of T)(handler As Csla.Validation.RuleHandler(Of T, Csla.Validation.RuleArgs), propertyName As String)': Type parameter 'T' for 'Public Sub AddRule(Of T)(handler As Csla.Validation.RuleHandler(Of T, Csla.Validation.RuleArgs), propertyName As String)' cannot be inferred.
'Public Sub AddRule(handler As Csla.Validation.RuleHandler, propertyName As String)': Method 'Public Function StringRequired(target As Object, e As Csla.Validation.RuleArgs) As Boolean' does not have the same signature as delegate 'Delegate Function RuleHandler(target As Object, e As Csla.Validation.RuleArgs) As Boolean'. "
Anyone have any idea what I am doing wrong?
Thanks,
Mike
mr_lasseter replied on Tuesday, November 28, 2006
Nevermind , it had something to do with their references.
Copyright (c) Marimer LLC