Exception on raising an event
Hello,
I'm developing an example project very similar to expense reporting (lab01), with two event handlers. I can fire the first one (submitted event) without any problems, but when I try to raise the second event (reviewed event) I get an exception that sais:
"EventDeliveryFailedException was unhandled" and the message is "Event "RevisatCOF" on interface type "WorkflowValidacio.Interficie" for instance id "ef46e5fa-64c7-4343-9d3c-c62b829f9c37" cannot be delivered."
I followed exactly the example in expense reporting, so I have the event declared in my interface and in the implementation class, and I raise the event like this:
RevisatCOFEventArgs e =newRevisatCOFEventArgs(Ident, ordre, review);if (this.RevisatCOF !=null){
Console.WriteLine("LOCAL: Llancem l'event RevisatCOF");this.RevisatCOF(null, e);}
Any ideas on why do I get that exception and how can I solve it?
Thank you very much,
Rubn
[1654 byte] By [
Samoyed] at [2007-12-23]
I checked the inner exception message and what I got was:
"The workflow hosting environment does not have a persistence service as required by an operation on the workflow instance \"4f33dcf0-ed73-408b-81c2-fe2b4093aa11\"
But I don't understand why it needs a persistence service, as I'm just raising a reviewed event...
I've been checking the expense reporting solution, and when I set the "expenseworkflow" as startup project and open the expenseapplication and manager from the exe files, it all works perfect. But if I start manually the host.exe and set "managerapplication" as startup project I get the same exception when raising the reviewed event, and I don't understand why that happens. I have the feeling that expensehost.exe does something that I havent noticed and that it makes the whole thing work well...
Please can someone help me?
Thanks,
Rubn
Still working on it but I find no way to solve it, can it be a bug of the RC version or am I doing something wrong (hosting, something about persistence...)?
Please need some help, I'm stuck at that exception and can't go on with the program.
Thanks
Rubn,
do you have 2 HandleExternalEventActivities in your workflow ? can you verify that your workflow is still runing and waiting when you trigger the second event ? (set a breakpoint in the second).
Serge
Serge Luca; Guidance Belgium; blog: www.redwood.be
Serge,
Yes I have 2 HandleExternalEvent, one for the submitted event and the second one for the reviewed event. Excuse me for my little knowledge on the subject but I'm quite new to this :-). I set a breakpoint in the second handle, then I submit a new order and it gets to that breakpoint. Then I let it run again (F5) and from the manager application I approve one of the purchase orders and it throws the exception. I've tried to do it without pressing F5 again when it stops at the breakpoint and same thing happens.
Rubn
Rubn,
When you instanciate both event, could you check that they are linked to the same workflowid ?I think the Runtime engine doesn't find the workflow...so either the workflow is not waiting for your second event or you 're targeting another workflow...
Serge
Serge Luca; Guidance Belgium; blog: www.redwood.be
Yes, when I create both EventArgs (SubmittedEventArgs and ReviewedEventArgs) I use the same InstanceId, if thats what you were asking. I generate a guid when I submit a new order and I use it everywhere (report, review, SubmittedEventArgs and ReviewedEventArgs), do I have to use it somewhere else or to check something? Thanks
Rubn
Rubn,
could you verify that your workflow is not completed after you trigger your first event ?
Serge,
I'm not at work right now to check it but I don't think it finishes. I have 2 code activities, one before the second event and one after the second event. They only print messages in console, and I see the first message, then the workflow reaches the breakpoint in the handle event, and it doesnt print the second message, so I suppose it is stopped waiting for the event, but if you want me to do any kind of test in order to verify that it really happens that way, please tell me how and I will do it tomorrow as soon as I go back to work.
Rubn
I've added an event for workflow completed and it doesnt get fired, so I suppose the workflow doesn't finish. But I'm not sure if I added it well, I added the event handler in the remote services class, after instantiating the runtime and before running it (in the function called from the constructor). I've put the function workflowRuntime_WorkflowCompleted in the remote services class too, and a console.writeline inside it to post a message if the workflow completes, and the message isn't posted. But I think I'm not doing it well because I've just added another eventhandler for the worflowStarted event and it doesn't print anything either... Still stuck in this problem, please help.
Thanks,
Rubn
Any help? Couldnt manage to solve that...
Thanks
Hi Samoyed -
can you share with us your EventArgs class? Also the service interface contract? Could you also do a quick check if the workflow guid reported in the exception is the same as the workflow that is currenltly running?
Also I am not clear on what you mean by you were creating a new order guid and using it. Could you elaborate a bit?
Thanks,
Vignesh
Hi Vignesh,
Thank you for your interest. When I said I create a new ordre guid and use it I mean: in the form where I enter the amount and submit the order, when I click submit I create a new guid (ordre.Ident = System.Guid.NewGuid();), where ordre is a variable of my OrdreCompra class (similar to a purchase order in expensereporting). I fill the rest of the ordre and submit it. And when I say I use it everywhere I mean that in the local services class when I create the event args and submit them I use that same guid that I created when submitting.
Right now I couldn't check that the workflow id in the exception is the same because before going on holidays I made some changes and now nothing works hehehe. But I remember I checked it before and it was the same guid, but if you want me to check something in particular please tell me.
The following is the interface class I created, including the EventArgs of both events:
using
System;using
System.ComponentModel;using
System.ComponentModel.Design;using
System.Collections;using
System.Workflow.ComponentModel;using
System.Workflow.ComponentModel.Design;using
System.Workflow.Runtime;using
System.Workflow.Activities;using
System.Workflow.Activities.Rules;namespace
WorkflowValidacio{
[
ExternalDataExchangeAttribute()]public interface Interficie{
void AcceptarOrdre(OrdreCompra ordre);void RebutjarOrdre(OrdreCompra ordre);event EventHandler<SolicitudRebudaEventArgs> SolicitudRebuda;event EventHandler<RevisatCOFEventArgs> RevisatCOF;}
[
Serializable]public class SolicitudRebudaEventArgs : ExternalDataEventArgs{
public SolicitudRebudaEventArgs(System.Guid InstanceId) : base(InstanceId) {
}
private OrdreCompra ordre;public OrdreCompra Ordre{
get { return ordre; }set { ordre = value; }}
}
[
Serializable]public class RevisatCOFEventArgs : ExternalDataEventArgs{
public RevisatCOFEventArgs(Guid InstanceId, OrdreCompra ordre, RevisioOrdre revisio):
base(InstanceId){
this.ordre = ordre;this.revisio = revisio;}
private OrdreCompra ordre;public OrdreCompra Ordre{
get { return ordre; }set { ordre = value; }}
private RevisioOrdre revisio;public RevisioOrdre Revisio{
get { return revisio; }set { revisio = value; }}
}
-
Thats it, hope this gives you some idea, cause I'm completely stuck. Thank you very much.
Rubn
Trying to find a solution for that, I came across an example in an SDK called "OrderingStateMachine", which is very similar in concept to ExpenseReporting, but uses a state machine instead of a sequential workflow. I've been having a look at it and I found it has a list of workflow instances and works a lot with them, and that sounds an interesting option. But appart from workflowinstance it uses statemachineworkflowinstance and changes its states, etc. But I dont really see the difference between them and how it uses them. In my case, in a sequential workflow, I only have the object "workflowinstance", so I wonder if I could do the same only with that... I'm not sure if I made myself clear, I mean I think that keeping a list of workflow instances could be useful for my project, but I don't really know how to deal with them and if I could use them in a sequential workflow in a similar way they're used in the state machine workflow example.
Or maybe that wouldnt solve anything in my project, I'm just trying to avoid that exception
Rubn
Rubn,
could you verify (in the debugger) that the instanceid generated when you create your workflow (
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication10.Workflow1));
instance.InstanceId // here
is the same that the instance id your EventArg receive ? how does your FireEvent function provides this Guid ? Do you harcode it ? I don't see it in your previous posts...