CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

Subclassing and validation rules

Last post 11-28-2006, 10:43 AM by mr_lasseter. 1 replies.
Sort Posts: Previous Next
  •  11-28-2006, 8:55 AM 9670

    Subclassing and validation rules

    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

  •  11-28-2006, 10:43 AM 9677 in reply to 9670

    Re: Subclassing and validation rules

    Nevermind , it had something to do with their references. 

View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems