himo

Hello ,

I have cretared WorkFlow.xml but i have this exception :

Cannot cretae workflow defenition . input markup is invalid

WorkFlow.xml :

<SequentialWorkflowActivity

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"

x:Class="WorkflowConsoleApplication1.HellowWorldWorkflow"

>

<DelayActivity

x:Name="codeActivity1"

TimeOutDuration="00.00.05" />

</SequentialWorkflowActivity>

Program.cs :

static void Main(string[] args)

{

using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())

{

AutoResetEvent waitHandle = new AutoResetEvent(false);

workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };

workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)

{

Console.WriteLine(e.Exception.Message);

waitHandle.Set();

};

XmlTextReader dr = new XmlTextReader("WorkFlow1.xml");

WorkflowInstance instance = workflowRuntime.CreateWorkflow(dr);

instance.Start();

waitHandle.WaitOne();

}

}

and i have cretaed class "HellowWorldWorkflow"

so what is the error whish raises this exception

thanks all

hema




Re: Windows Workflow Foundation Declarative WorkFlow

Tom Lake - MSFT

You have three problems with the xoml file. First the delay's property name is TimeoutDuration, next the value for that property is in the incorrect format and should be 00:00:05 and finally you need to remove the x:Class attribute since this is only used when the workflow is compiled. After making these changes you are left with the following:

<SequentialWorkflowActivity xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">

<DelayActivity x:Name="codeActivity1" TimeoutDuration="00:00:05" />

</SequentialWorkflowActivity>

If you havení»t already you should take a look at the blog post at http://blogs.msdn.com/tomlake/archive/2006/05/02/xaml-activation-and-how-to-use-it.aspx.






Re: Windows Workflow Foundation Declarative WorkFlow

himo

Hello ,

Thanks to reply me , and it was helpful for me

but the sample i gave it to u , u told me remove x:class .

now I want to add this class .....what can i do

becuase when i added it again , it gives me error :

this is what i adedded :

1- *** x:Class="MyClass"

***

<CodeActivity

x:Name="codeActivity1"

ExecuteCode="Run"/>

2-

public partial class MyClass : SequentialWorkflowActivity

{

private void Run(object sender, EventArgs e)

{

Console.WriteLine("Welcome");

}

}

error is :

'x:Class' cannot be used when the markup is executed directly without creating a new activity type.

Activity 'codeActivity1' validation failed: Method 'Run' could not be resolved. Either method could not be found or method signature does not match the delegate type






Re: Windows Workflow Foundation Declarative WorkFlow

Tom Lake - MSFT

With Xaml activation you can not have a code beside file. If you need to use code handlers you will need to build them into your base workflow and use activity binding to bind to the handler, make sure the handler is public. The syntax would be the following:

ExecuteCode="{ActivityBind Workflow1,Path=Run}"






Re: Windows Workflow Foundation Declarative WorkFlow

himo

Hello ,

Thanks for ur reply .

I did everything u gave it to me but it gives me this Exception:

'x:Class' cannot be used when the markup is executed directly without creating a new activity type

Activity 'codeActivity1' validation failed: Cannot resolve Activity 'Workflow1'

could u tell me how i can solve this errors

thanks






Re: Windows Workflow Foundation Declarative WorkFlow

Dessus

Tom Lake - MSFT wrote:

With Xaml activation you can not have a code beside file. If you need to use code handlers you will need to build them into your base workflow and use activity binding to bind to the handler, make sure the handler is public. The syntax would be the following:

ExecuteCode="{ActivityBind Workflow1,Path=Run}"



I am in a situation myself where i have a xoml file and a .rules file and I have removed the code file as i need to edit the .rules at runtime. Instead of starting a new thread i am posting here. I am wondering how I go about:

1. building them into your base workflow. what is this base workflow (bear with me here, i am new to WF).
2. use activity binding to bind to the handler (again lost me here).

Could i get a basic code sample. I am sure this would help both of us.

Thanks
Richard




Re: Windows Workflow Foundation Declarative WorkFlow

Tom Lake - MSFT

Richard,

A base workflow is a workflow that derives from SequentialWorkflowActivity or StateMachineWorkflowActivity that contains any properties, variables or handlers that will be needed in you xoml only workflow. Instead of deriving your xoml only workflow from SeqentialWorkflowActivity or StateMachineWorkflowActivity you then derive from this new base workflow. Take a look at the blog post I added a link for in my first post in this thread for a sample.






Re: Windows Workflow Foundation Declarative WorkFlow

Zaph0d

What about XOML only activities

Is it possible to use the method above to create a (dynamic) XOML only activity and then call this from an existing compiled workflow

If so, how do I go about this

Also, would this activity still be able to participate in an exsting transactionscope in the compiled workflow

Thanks