What Was I Thinking?

Follies & Foils of .NET Development
posts - 95 , comments - 352 , trackbacks - 0

Workflow Validation Exception: Condition Not Found

Recently I migrated one of my solutions from .net 3.0 to .net 3.5.  For the most part the migration went smoothly, except for an issue with the type provider, and XAML activated workflows that included accompanying .rules files.

I was able to load and work with the workflows in the Visual Studio designer, but they would fail execution at runtime:

line 402
error 1342: Activity 'PersistWasSucessful' validation failed: Can not find the condition "ParticipationSaved". --->  System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation..

Typically the "Condition Not Found" error is the result of the .rules file not being loaded at the same time as the workflow. Since I hadn't changed my workflow loading codebase, It seemed an unlikely candidate.

The problem had nothing to do with the Workflow Runtime, but rather a change in how the Rules Files are stored as embedded resources. Thank You "Lutz Roeder's Reflector"!

In .NET 3.0, a XAML WF with a rules file called MyWorkflow in the WorkflowLibrary assembly would have the following resource names:


*note the duplication of the .rules suffix on the resource name *

in .NET 3.5 the same workflow has the following resource names:


So 2 things have changed here; the duplication of the .rules suffix (a likely bug that was fixed) is no longer present, and the rules file is saved without the namespace.

After changing my WF hosting logic to extract the rules file using the new naming convention, the rules are once again getting loaded into my runtime and workflows are executing.

Print | posted on Wednesday, December 12, 2007 8:29 AM | Filed Under [ Visual Studio ]



# re: Workflow Validation Exception: Condition Not Found


great post!
But what did you change to reload the Workflow Rules???

I have a similiar problem after upgrading to VS2008 but only with one Activity.
1/30/2008 5:56 AM | nadine

# re: Workflow Validation Exception: Condition Not Found

Another great tip. THank you!
5/12/2008 10:44 AM | Blackberry 9000 Review

# re: Workflow Validation Exception: Condition Not Found

I read the rules XAML from my resource files (from the resource file into a stream object, from the stream object into the xmlTextReader.

When I load the workflow into the runtime, I use the overload that takes xmltextreaders for the workflow and rule defintions.

The code for loading the workflow and rules into the runtime is:
wfInstance = runtime.CreateWorkflow(rdrWorkflow, rdrRules, null);
5/24/2008 1:48 PM | wtfChris

# re: Workflow Validation Exception: Condition Not Found

I'm getting this error as well, and I can't find a fix for it. The project was created in .NET 3.5 from the get-go, and a nearly identical test project works fine. If I remove all use of Declarative rules from the workflow it runs fine, but the moment I use even one DR it dies with a validation error on instantiation. I do not have my WF seperated out into a XOML file, so using the xmltextreaders overload is not possible. My basic project structure is a WCF web-service (hosted in a web-app project), that references the Workflow project. I am losing hair and have to show this working next Friday. I know this should work, as my test project does, but this one just refuses to. Any ideas?
7/31/2008 5:39 PM | CoderX

# re: Workflow Validation Exception: Condition Not Found

This error happened to me with a new 3.5 project. I got the error when the app run, and when I tried to change the rule I got "Value does not fall whitin the expected range".
The problem was that the rules file was with lowercase letter, like myworkflow1.rules, but the cs and xoml file were like MyWorkflow.
To fix that:
1. unload the project (RightClick->Unload)
2. change the file name from windows explorer.
3. Open your csproj file with notepad and change the file name where ever you find it.
4. Reload the project.
9/11/2008 7:24 AM | Amiram

# re: Workflow Validation Exception: Condition Not Found

Open the .csproj file in Notepad
Find the section where the .rules file is referenced. It will look something like this:
<EmbeddedResource Include="MyWorkflow.rules" />
Alter this tag to include the DependentUpon tag:
<EmbeddedResource Include="MyWorkflow.rules" >
Save the .csproj file
Recompile the solution
2/20/2009 12:50 AM | yasirj

# re: Workflow Validation Exception: Condition Not Found

Well, turns out naming IS the issue. I had only gone part way. For a workflow to work correctly with rules it must be named the exact same name as the class.
5/25/2009 12:13 AM | LE

# re: Workflow Validation Exception: Condition Not Found

I had a similar issue. The workflow failed to start on adding declarative rules condition. Though the .rules reference and its dependency on .cs file existed in the project file the workflow failed to start. It turned out to be an issue with the naming of the .rules file. It needs to be exactly same as the class name (not the .cs file name) Thanks to the last solution provider here.
10/18/2009 5:24 AM | spjack

# re: Workflow Validation Exception: Condition Not Found

my code in .csproj already like this:

<EmbeddedResource Include="Workflow1.rules">

when I try to re-deploy it still not successed..
Please help.>!!
11/16/2009 3:46 AM | Malik

# re: Workflow Validation Exception: Condition Not Found

Me too. Is there any solution? Thanks!
11/24/2010 1:46 AM | Bin
Post A Comment

Powered by: