ValidationErrorCollection.HasErrors Property


Indicates whether the collection contains ValidationError objects that indicate compilation errors.

Namespace:   System.Workflow.ComponentModel.Compiler
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

public bool HasErrors { get; }

Property Value

Type: System.Boolean

true if the activity has generated validation errors; otherwise, false.

If an Activity has generated a warning, the warning is considered an error in the context of this property.

The following example shows how to create and manipulate a validation error collection as part of a custom validation routine.

This code example is part of the Send E-mail SDK sample and is from the SendMailActivity.cs file. For more information, see Send Mail Activity.

public class SendEmailValidator : System.Workflow.ComponentModel.Compiler.ActivityValidator
    // Define private constants for the Validation Errors 
    private const int InvalidToAddress = 1;
    private const int InvalidFromAddress = 2;
    private const int InvalidSMTPPort = 3;

    //customizing the default activity validation
    public override ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)

        // Create a new collection for storing the validation errors
        ValidationErrorCollection validationErrors = base.ValidateProperties(manager, obj);

        SendEmailActivity activity = obj as SendEmailActivity;
        if (activity != null)
            // Validate the Email and SMTP Properties
            this.ValidateEmailProperties(validationErrors, activity);
            this.ValidateSMTPProperties(validationErrors, activity);
        return validationErrors;

.NET Framework
Available since 3.0
Return to top