I am new to wwf and in working with callExternalMethod I am continuously getting a EventDeliveryFailedException error, which I am unable to solve. I have seen several messages about this error in this forum, but none of them matches my situation and has pointed me to the proper solution. My code is based on the examples in lab5, but it is slightly different.
Here is a description of my case and problem:
I use a sequential workflow with a callExternalMethod as the last activity. This callExternalMethod is used to pass back data to the process invoking the workflow, which happens to be a console application.
After calling the method of the interface used by callExternalMethod I get the following error:
Unhandled Exception: System.Workflow.Activities.EventDeliveryFailedException: Event "CompanySet" on interface type "CompanyShit.ICom
panyReturnService" for instance id "5a766c86-2e1d-408f-9687-826cfa535a44" cannot be delivered. ---> System.InvalidOperationException
: Event Queue operation failed with MessageQueueErrorCode QueueNotFound for queue 'Message Properties
Interface Type:CompanyShit.ICompanyReturnService
Method Name:CompanySet
CorrelationValues:
'.
at System.Workflow.Runtime.WorkflowQueuingService.GetQueue(IComparable queueID)
at System.Workflow.Runtime.WorkflowQueuingService.EnqueueEvent(IComparable queueName, Object item)
at System.Workflow.Runtime.WorkflowExecutor.EnqueueItem(IComparable queueName, Object item, IPendingWork pendingWork, Object work
Item)
at System.Workflow.Runtime.WorkflowInstance.EnqueueItem(IComparable queueName, Object item, IPendingWork pendingWork, Object work
Item)
at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)
--- End of inner exception stack trace ---
at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at CompanyShit.CompanyReturnService.SetCompanyName(Object o) in D:\vsprojects\wwf\AvhWwfTest1\CompanyShit\CompanyReturnService.cs
:line 61
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
When running in debug I can see that it fails within the interface method, which returns the data to the process invoking the workflow. Here is this specific piece of code:
public void SetCompanyName(object o)
{
CompanyReturnEventArgs companyEventArgs = o as CompanyReturnEventArgs;
if (CompanySet != null)
{
CompanySet(null, companyEventArgs);
}
}
The strange thing is that the call to CompanySet(null, companyEventArgs) works fine, but the exception is thrown the moment it comes back into this piece of code (so just before leaving the "if").
By the way, I am using wwf 2.2.
Regards,
Andre

Obscure Error: EventDeliveryFailedException
Jesper Lund Stocholm
When you use local communications to communicate between your workflow and the host, you do so with an interface marked with ExternalDataExchange. This indicates the methods the workflow can/will call and the events that it will handle/listen for.
when you add your local service implementation of this interface to the ExternalDataExchangeService, it looks for all events on the interface and registers handlers for them. So, when you raise that event, it tries to deliver it to your workflow.
What you should do is the following:
Define your interface as you have probably already done because this is needed to communicate to the host from the workflow.
In that interface, only include the method you are calling, since the event you are raising is not intended for the worklfow, and therefore should not be part of your interface.
Implement a local service that implements your interface. In addition, add the event defintion and logic into this service. Note that becuase this is not part of the interface, these events will not get raised to the workflow, but can instead be handled by your host.
In your method call, raise the event which, if you have a handler in your host, will get handled.
Based on what you have described so far, I'm guessing that you can simply go to your interface defintion and remove the event definition from it and you'll be up and running with your existing code.
HTH,
Matt
Sugarmag
Hello Matt,
The scenario I am trying to implement is that an activity within a workflow passes data back to the calling program after which the workflow can finish (or continue doing other stuff). The "process" of passing data back to the calling program has no interest in communicating back to the workflow. So the solution to my problem lies within the following part of your reply:
If you don't want this to happen, then don't include the event in your external data exchange interface defintion. You can still have the event on the service and raise it for your host to handle
Based on this I have tried several things but they all failed. Basically I do not understand (I think) how you can use events for communicating between an activity in a workflow and the calling program without using a external data exchange service. Can you perhaps explain this in a bit more detail or point me to some documentation or examples
Thanks and regards,
Andre
tnrajesha
Andre'
You are raising an event which workflow is trying to route back to your workflow instance. If you don't want this to happen, then don't include the event in your external data exchange interface defintion. You can still have the event on the service and raise it for your host to handle, but if you put it on the interface, then runtime assumes you want to send those events into the workflow. If you do want to send them into the workflow you should a) use the HandleExternalEvent activity and b) raise the event outside of your method call so that the workflow can move on to the next activity and you don't get a race condition.
Matt
ansilb
Andre, I think in this case the best way to communicate from the wrokflow to the host is to use an Callexternalmethod activity.
To get a nice overview of this, take a look at the following videos (from Mike Taulty, MS UK) :
http://mtaulty.com/blog/(30iryrbzauuckf55yhccbs45)/archive/2006/04/11/9301.aspx
("workflow to host communication")
Hope this helps
Serge Luca
Guidance, Belgium
www.redwood.be
chteng
Andre, according to your code, it seems to me that CompanySet is an event the workflow is waiting for after calling the external method (SetCompanyName) on the host; so why do you try to trigger this event if you want your workflow to go ahead
Serge luca
Guidance, Belgium
www.redwood.be
AndrewWheeler
Hello Matt,
Brilliant. Your suggestion of removing the event definition from the interface fixed it.
I knew it had to be something this simple. It just shows that I still have a lot to learn about wwf.....
Thanks and regards,
Andre
charlie_pike
Hello Serge,
I was thinking (and hoping) that it wouldn't be necessary to use an additional HandleExternalEvent. I am not interested in passing back any information to the workflow, because after sending data to the calling program the workflow can just finish (and the calling program can just continue processing the data it received from the workflow).
Thanks and regards,
Andre
wieda
Andre,
shouldn't you have an HandleExternalEvent activity waiting for your CompanySet event AFTER your callExternalMethod activity
Serge Luca
Guidance, Belgium
www.redwood.be
fenrir
Hello Serge,
I trigger this event because I thought that this was the only way to transfer data from an activity in a workflow to the calling program. If this is not true or there is a better strategy for achieving this, please tell me and I will change my approach.
Thanks and regards,
Andre