This documentation is archived and is not being maintained.

How to: Display Validation Errors in a Rehosted Designer

This topic applies to Windows Workflow Foundation 4 (WF4).

This topic describes how to retrieve and publish validation errors in a rehosted Windows Workflow Designer. This provides us with a procedure to confirm that a workflow in a rehosted designer is valid.

This task has two parts. The first is to provide an implementation IValidationErrorService. There is one critical method to implement on this interface, ShowValidationErrors which will pass you a list of ValidationErrorInfo objects containing information about the errors to the debug log. After implementing the interface, you retrieve the error information by publishing an instance of that implementation to the editing context.

Implement the IValidationErrorService Interface

  1. Here is a code sample for a simple implementation that will write out the validation errors to the debug log.

    
    using System.Activities.Presentation.Validation;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    
    namespace VariableFinderShell
    {
        class DebugValidationErrorService : IValidationErrorService
        {
            public void ShowValidationErrors(IList<ValidationErrorInfo> errors)
            {
                errors.ToList().ForEach(vei => Debug.WriteLine(string.Format("Error: {0} ", vei.Message)));
            }
        }
    }
    

Publishing to the Editing Context

  1. Here is the code that will publish this to the editing context.

    
    wd.Context.Services.Publish<IValidationErrorService>(new DebugValidationErrorService());
    
Show: