Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workflow Foundation 4.5 "Expression Activity type 'CSharpValue`1' requires compilation in order to run."

I am working through the Getting Started Tutorial for WF45 and have run into a problem that looks to have been experience by other people, but not in the same way that I am experiencing it. I am hoping that someone else has a solution for me.

When I work through the Tutorial, all is good till I have to run it from the workflow host. At that point the instantiation of the workflow fail and returns the following message.

"Expression Activity type 'CSharpValue`1' requires compilation in order to run. Please ensure that the workflow has been compiled."

I have tried downloading the source from Windows Workflow Foundation (WF45) - Getting Started Tutorial in case I had missed a step but the error still persists.

Reading online it seems that workflows with embedded C# expressions need to be complied, but as I understand it this happens by default when using VS2012 and the workflow designer? I have tried to implement the CompileExpressions method found here but that did not help. I did read that there was a problem during the pre-release version where C# expressions caused this problem, and yet VB projects worked. Testing this, I see that I am suffering this exact case. The VB tutorial runs fine, but the C# version fails with this exception.

Furthermore and dare I mention it: This is not a problem on my colleague's machine, so I think it is a configuration problem on my machine...

Update & dodge fix:

So, I have managed to fix the problem, although I am not happy with the solution and would love to hear if anyone has a decent reason for this happening.

My fix was to replace my Microsoft.Common.targets file in the \Framework\v4.0.30319 folder with my colleague's version of the same file. This has solved the problem. What else it has broken remains to be seen...

like image 307
FryHard Avatar asked Jan 09 '13 06:01

FryHard


2 Answers

The original Problem thread is pretty old, but may be your find that helpfull either.

I had the same Problem with my dynamic activities and found that the documentation is wrong:

This is the code which produces the error above:

string path = @"myActivity.xaml";

            Activity activity = ActivityXamlServices.Load(path);



            IDictionary<string, object> dictionary = new Dictionary<string, object>
            {
                { "Arg", 1},
            };

            IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);

and this is the working code:

string path = @"myActivity.xaml";

            ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
            {
                CompileExpressions = true
            };


            Activity activity = ActivityXamlServices.Load(path, settings);

            IDictionary<string, object> dictionary = new Dictionary<string, object>
            {
                { "ArgNumberToEcho", 2},
            };

            IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);
like image 190
user2216337 Avatar answered Oct 29 '22 10:10

user2216337


This might help someone - what worked for me was I had line breaks in the Expression window for one my of Assigns. Removed the line breaks and it started working.

like image 21
Vivek Avatar answered Oct 29 '22 10:10

Vivek