locked
System.Workflow.Activities.EventDeliveryFailedException

    Question

  • Here is my situation

    I have a approval flow which the state and event is create by custom, so the workflow is dynamic.

    I use a program to create a statemachine workflow like "OutlookWorkflowWizard" base on user's choice because its a statemachine workflow, except for create xoml file, i also have to build the localservice dynamically as well.

    after that, i will run the workflow.

    when I use xaml activation, the workflow runs and persists well, but there's one thing, every i create a single workflow instance  based on the same xaml, there will be a new entry in Workflow table in the sharedstore, I don't know why, and I think it's not good, so I try not to use xaml activation.

    So, I add class attribute to the xoml file, compile it to assembly, create the workflow by type, but the program can not run, the exception is:

     

    Error 54 TestCase 'M:Core.Workflows.TestWorkflow.TestRunWorkflow'
    failed: Exception has been thrown by the target of an invocation.
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Workflow.Activities.EventDeliveryFailedException: Event "Submit" on interface type "Custom.Workflow.ILocalService_872316c48ccc438d88c3741a1a03695c" for instance id "02d30d28-6917-4aed-8dc9-60f0ebe10299" cannot be delivered. ---> System.InvalidOperationException: Workflow with id "02d30d28-6917-4aed-8dc9-60f0ebe10299" not found in state persistence store.
       at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTime timeout)
       at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.LoadWorkflowInstanceState(Guid id)
       at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
       at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
       at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
       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 Custom.Workflow.LocalService_872316c48ccc438d88c3741a1a03695c.RaiseSubmit(Object sender, OmsWorkflowEventArgs e)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at Core.Workflows.TestWorkflow.TestRunWorkflow() in E:\Development\WorkflowTest\TestWorkflow.cs:line 132 E:\Development\WorkflowTest\TestWorkflow.cs 132 

    Monday, May 28, 2007 9:25 AM

Answers

  • Add an AppDomain assembly resolver where you are starting the workflow runtime, like the following, so that you can return the assembly that can be found:

     

    Code Snippet

    AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)

    {

        Assembly resolvedAssembly = null;

     

        //  If it is a type you know about return the assembly

        if (args.Name.Equals(this.GetType().Assembly.FullName))

        {

            resolvedAssembly = this.GetType().Assembly;

        }

     

        return resolvedAssembly;

    };

     

    Wednesday, May 30, 2007 3:11 AM
  • Mirricle,

     

    - to your question about the duplicated workflowtypes - see this thread

     

    - Note, the workflowdefinition is cached based on the calculated hash value from the xoml stream, if this xomlHasCode is not found in the cache, the new workflowdefinition is created. Therefore, if your xoml file has been changed (for instance, you add more whitespaces), the WorkflowRuntime will handle this xoml as a new definition.

     

     

    Thanks

     

    Roman

     

    Wednesday, May 30, 2007 3:54 AM

All replies

  • any one?
    Tuesday, May 29, 2007 12:37 AM
  • below is the type based workflow code , and throw the exception above

     

    LocalService_872316c48ccc438d88c3741a1a03695c.dll is the localservice which is generated by codedom and then compliled

    CustomWorkflow872316c48ccc438d88c3741a1a03695c.dll is the workflow type which is complile the by a xoml file

     

    Code Snippet

                Assembly assembly = Assembly.LoadFrom(@"E:\Temp\LocalService_872316c48ccc438d88c3741a1a03695c.dll");
                Type type = assembly.GetTypes()[1];

                WorkflowManager manager = new WorkflowManager("WorkflowRuntime");

                WorkflowInstance workflowInstance = null;
                try
                {
                    Dictionary paramDict = new Dictionary();
                    paramDict.Add("Argument", new OmsWorkflowEventArgs(System.Guid.NewGuid(), 1));
                    paramDict.Add("Sender", new object());

                    Assembly wassembly = Assembly.LoadFrom(@"E:\Temp\CustomWorkflow872316c48ccc438d88c3741a1a03695c.dll");
                    Type wtype = wassembly.GetTypes()[0];

                    //workflowInstance = manager.Runtime.CreateWorkflow(reader, null, paramDict);
                    workflowInstance = manager.Runtime.CreateWorkflow(wtype, paramDict);
                }
                catch (WorkflowValidationFailedException ex)
                {
                    StringBuilder errors = new StringBuilder();

                    foreach (ValidationError error in ex.Errors)
                    {
                        errors.AppendLine(error.ToString());
                    }
                    Console.WriteLine(errors.ToString(), "Compile error");
                    throw new Exception(errors.ToString());
                }

                workflowInstance.Start();
                Guid id = workflowInstance.InstanceId;
                manager.Scheduler.RunWorkflow(id);

                System.Threading.Thread.Sleep(1000);

                object local = manager.GetLocalService(type);
                local.GetType().GetMethod("RaiseSubmit").Invoke(local, new object[] { new object(), new OmsWorkflowEventArgs(id, 2) });
                manager.Scheduler.RunWorkflow(id);

                System.Threading.Thread.Sleep(1000);

                local.GetType().GetMethod("RaisePublish").Invoke(local, new object[] { new object(), new OmsWorkflowEventArgs(id, 2) });
                manager.Scheduler.RunWorkflow(id);

     

    below is the xaml based workflow code, worked fun, but every time there will be a new entry of workflow type in database

     

    Code Snippet

    WorkflowManager manager = new WorkflowManager("WorkflowRuntime");

                XmlReader reader = XmlReader.Create(@"E:\Development\OMS Project\OMS Framework\OMS Rebuild\WorkflowActivityLibrary\CustomWorkflow.xoml");

                WorkflowInstance workflowInstance = null;
                try
                {
                    Dictionary paramDict = new Dictionary();
                    paramDict.Add("Argument", new OmsWorkflowEventArgs(System.Guid.NewGuid(), 1));
                    paramDict.Add("Sender", new object());

                    workflowInstance = manager.Runtime.CreateWorkflow(reader, null, paramDict);
                }
                catch (WorkflowValidationFailedException ex)
                {
                    StringBuilder errors = new StringBuilder();

                    foreach (ValidationError error in ex.Errors)
                    {
                        errors.AppendLine(error.ToString());
                    }
                    Console.WriteLine(errors.ToString(), "Compile error");
                    throw ex;
                }

                workflowInstance.Start();
                Guid id = workflowInstance.InstanceId;
                manager.Scheduler.RunWorkflow(id);

                System.Threading.Thread.Sleep(1000);

                object local = manager.GetLocalService(type);
                local.GetType().GetMethod("RaiseSubmit").Invoke(local, new object[] { new object(), new OmsWorkflowEventArgs(id, 2) });
                manager.Scheduler.RunWorkflow(id);

                System.Threading.Thread.Sleep(1000);

                local.GetType().GetMethod("RaisePublish").Invoke(local, new object[] { new object(), new OmsWorkflowEventArgs(id, 2) });

     

     

    below is workflow manager

    Code Snippet

     

        public class WorkflowManager
        {
            private WorkflowRuntime runtime;

            public WorkflowRuntime Runtime
            {
                get { return runtime; }
            }

            public WorkflowManager(string configSectionName)
            {
                runtime = new WorkflowRuntime(configSectionName);
                runtime.StartRuntime();           
            }

            public ExternalDataExchangeService ExternalDataDataExchange
            {
                get
                {
                    return Runtime.GetService<ExternalDataExchangeService>();               
                }
            }

            public ManualWorkflowSchedulerService Scheduler
            {
                get
                {
                    return Runtime.GetService<ManualWorkflowSchedulerService>();
                }
            }

            public object GetLocalService(Type type)
            {
                object service = (object)Runtime.GetService(type);
                if (service == null)
                {
                    service = (object)Activator.CreateInstance(type);
                    ExternalDataDataExchange.AddService(service);
                }
                return service;
            }
        }

     

     

     

    Tuesday, May 29, 2007 2:36 AM
  • help
    Tuesday, May 29, 2007 2:40 AM
  • Mirricle,

     

    - In your case, the error message "Workflow with id "02d30d28-6917-4aed-8dc9-60f0ebe10299" not found in state persistence store" can happen when an event message can not be delivered to the terminated, completed or not existed workflow.

     

    - To figure out the workflow state, log the WorkflowRuntime event handlers in the Trace. Also, you can check a workflow instance before the raising an event using the GetWorkflow(instanceId) method.

     

    Thanks

     

    Roman    

     

    Tuesday, May 29, 2007 2:47 AM
  •             runtime.WorkflowStarted += new EventHandler<WorkflowEventArgs>(runtime_WorkflowStarted);
                runtime.WorkflowUnloaded += new EventHandler<WorkflowEventArgs>(runtime_WorkflowUnloaded);
                runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(runtime_WorkflowIdled);
                runtime.WorkflowLoaded += new EventHandler<WorkflowEventArgs>(runtime_WorkflowLoaded);
                runtime.WorkflowPersisted += new EventHandler<WorkflowEventArgs>(runtime_WorkflowPersisted);
                runtime.WorkflowCreated += new EventHandler<WorkflowEventArgs>(runtime_WorkflowCreated);
                runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(runtime_WorkflowCompleted);

     

    i did this

    and found that

     

    WorkflowIdled  WorkflowUnloaded WorkflowLoaded  didn't invoked in first case

    Tuesday, May 29, 2007 3:03 AM
  • and why in the xaml activation case, there are duplicated workflowtypes
    Tuesday, May 29, 2007 3:07 AM
  • Mirricle,

     

    - could you post your config file?

     

    Thanks

     

    Roman

    Tuesday, May 29, 2007 4:15 AM
  • I found the problem of the "type" case.

    because workflowruntime cound not find the localservice and workflow which is located in e:\temp

    i copied them to bin, then the program ran well.

    is there a way let the run time find the assmebly without put the dll into the bin directory?

    looked like the Assmebly.Loadfrom didn't work.

    and

                AssemblyName an = AssemblyName.GetAssemblyName(@"E:\Temp\LocalService_872316c48ccc438d88c3741a1a03695c.dll");
                Assembly assembly = Assembly.Load(an);

    either

     

    the config file is below

     

     
    Code Snippet
    <configSections>
      <section name="WorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     </configSections>
     <!--Tracking Workflow unnoticed exceptions-->
     <system.diagnostics>
      <switches>
       <add name="System.Workflow LogToTraceListeners" value="1" />
       <add name="System.Workflow.Runtime.Hosting" value="All" />
       <add name="System.Workflow.Runtime" value="All" />
       <add name="System.Workflow.Runtime.Tracking" value="All" />
       <add name="System.Workflow.Activities" value="All" />
      </switches>
      <trace autoflush="true" indentsize="4">
       <listeners>
        <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="WFTrace.log" />
       </listeners>
      </trace>
     </system.diagnostics>

     

     <WorkflowRuntime Name="WorkflowServiceContainer">
      <CommonParameters>
       <!--Workflow Tracking and SqlPersistence ConnectionString(Shared)-->
       <add name="ConnectionString" value="server=(local);user id=sa;password=!QAZ2wsx;database=SharedStore;"/>
      </CommonParameters>
      <Services>
       <add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       <add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       <add type="System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" UnloadOnIdle="true"/>
       <add type="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" IsTransactional="false"/>
      </Services>
     </WorkflowRuntime>

     

    Tuesday, May 29, 2007 4:24 AM
  • Hi Mirricle

     

    Does Assembly.Load throw any exception or is it more like the type is not being found?

     

    Thanks

    -ram

     

     

    Tuesday, May 29, 2007 8:08 PM
  • No Assembly.Load  did not throw any exception, there's no expilicit exceptions

     

    when i put localservice and workflow dlls to bin, every thing is ok.

    and when put the dll in a directory other than bin, the Idle, Unload, Load events don't invoke

    and "local.GetType().GetMethod("RaiseSubmit").Invoke(local, new object[] { new object(), new OmsWorkflowEventArgs(id, 2) });"

    run failed. you can see the trace log,

     

    Code Snippet

    System.Workflow.Runtime Start: 0 : Workflow Runtime tracer is alive!
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime: Created WorkflowRuntime c464768b-250d-40a6-9342-337db13576c5
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime: Starting WorkflowRuntime c464768b-250d-40a6-9342-337db13576c5
    System.Workflow.Runtime.Hosting Information: 0 : SharedConnectionWorkflowCommitWorkBatchService: Starting
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService(00000000-0000-0000-0000-000000000000): Starting, LoadInternalSeconds=120
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService OpenConnection start: 05/29/2007 03:25:12
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService. OpenConnection end: 05/29/2007 03:25:12
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService.RetrieveNonblockingInstanceStateIds ExecuteReader start: 05/29/2007 03:25:12
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService.RetrieveNonblockingInstanceStateIds ExecuteReader end: 05/29/2007 03:25:12
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime: Started WorkflowRuntime c464768b-250d-40a6-9342-337db13576c5
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime dispensing resource, instanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : Creating instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime Information: 0 : Queuing Service: Creating new Queue with ID -37063737 for *PendingNotifications
    System.Workflow.Runtime.Hosting Information: 0 : TimerEventSubscriptionQueue: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 Created
    System.Workflow.Runtime Information: 0 : Adding context 1:EditorialWorkflow
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime:: replacing unusable executor for key ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 with new one (hc: 28840036)
    System.Workflow.Runtime Information: 0 : Queuing Service: Creating new Queue with ID -1049144842 for Message Properties
    Interface Type:Yourzine.Oms.Custom.Workflow.ILocalService_872316c48ccc438d88c3741a1a03695c
    Method Name:Submit
    CorrelationValues:

    System.Workflow.Runtime Information: 0 : Queuing Service: Creating new Queue with ID 1406864771 for Message Properties
    Interface Type:Yourzine.Oms.Custom.Workflow.ILocalService_872316c48ccc438d88c3741a1a03695c
    Method Name:Reject
    CorrelationValues:

    System.Workflow.Runtime Information: 0 : Queuing Service: Creating new Queue with ID 1213984649 for Message Properties
    Interface Type:Yourzine.Oms.Custom.Workflow.ILocalService_872316c48ccc438d88c3741a1a03695c
    Method Name:Publish
    CorrelationValues:

    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteReaderRetried ExecuteReader start: 05/29/2007 03:25:14
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteReaderRetried ExecuteReader end: 05/29/2007 03:25:14
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstance start: 05/29/2007 03:25:15
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstance end: 05/29/2007 03:25:15
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent start: 05/29/2007 03:25:15
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent end: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime dispensing resource instanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, hc: 28840036
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=00000000-0000-0000-0000-000000000000
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent end: 05/29/2007 03:25:16
    System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: EditorialWorkflow Old:Initialized; New:Executing
    System.Workflow.Runtime.Tracking Information: 0 : TrackingListener::ActivityStatusChange - Received Activity Status Change Event for activity EditorialWorkflow
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance end: 05/29/2007 03:25:16
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Scheduling entry: ActivityOperation((1)EditorialWorkflow, Execute)
    System.Workflow.Runtime.Hosting Information: 0 : ManualWorkflowSchedulerService: Schedule workflow ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=00000000-0000-0000-0000-000000000000
    System.Workflow.Runtime.Hosting Information: 0 : ManualWorkflowSchedulerService: Running workflow ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : ManualWorkflowSchedulerService: CanRun is True
    System.Workflow.Runtime.Hosting Information: 0 : ManualWorkflowSchedulerService: Executing ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : Running workflow ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Running scheduled entry: ActivityOperation((1)EditorialWorkflow, Execute)
    System.Workflow.Runtime Information: 0 : Queuing Service: Creating new Queue with ID -2007973686 for SetStateQueue
    System.Workflow.Runtime Error: 1 : Execute of Activity EditorialWorkflow threw System.IO.FileNotFoundException: Could not load file or assembly 'LocalService_872316c48ccc438d88c3741a1a03695c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. File name: 'LocalService_872316c48ccc438d88c3741a1a03695c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(String assemblyString)
       at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
       at System.Runtime.Serialization.ObjectManager.DoFixups()
       at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
       at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter)
       at System.Workflow.ComponentModel.Activity.Clone()
       at System.Workflow.ComponentModel.ActivityExecutionContextManager.CreateExecutionContext(Activity activity)
       at System.Workflow.Activities.StateActivity.ExecuteChild(ActivityExecutionContext context, Activity childActivity)
       at System.Workflow.Activities.ExecuteChildStateAction.Execute(ActivityExecutionContext context)
       at System.Workflow.Activities.StateMachineExecutionState.ProcessActions(ActivityExecutionContext context)
       at System.Workflow.Activities.StateActivity.ExecuteRootState(ActivityExecutionContext context)
       at System.Workflow.Activities.StateActivity.Execute(ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.CompositeActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutionFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Done with running scheduled entry: ActivityOperation((1)EditorialWorkflow, Execute)
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent end: 05/29/2007 03:25:16
    System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: EditorialWorkflow Old:Executing; New:Faulting
    System.Workflow.Runtime.Tracking Information: 0 : TrackingListener::ActivityStatusChange - Received Activity Status Change Event for activity EditorialWorkflow
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance end: 05/29/2007 03:25:16
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Scheduling entry: ActivityOperation((1)EditorialWorkflow, HandleFault)
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Running scheduled entry: ActivityOperation((1)EditorialWorkflow, HandleFault)
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Scheduling entry: SubscriptionEvent((1)EditorialWorkflow, ActivityStatusChange('(1)EditorialWorkflow', Faulting, Faulted))
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Done with running scheduled entry: ActivityOperation((1)EditorialWorkflow, HandleFault)
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Running scheduled entry: SubscriptionEvent((1)EditorialWorkflow, ActivityStatusChange('(1)EditorialWorkflow', Faulting, Faulted))
    System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: EditorialWorkflow Old:Faulting; New:Closed
    System.Workflow.Runtime.Tracking Information: 0 : TrackingListener::ActivityStatusChange - Received Activity Status Change Event for activity EditorialWorkflow
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertActivityStatusInstance end: 05/29/2007 03:25:16
    System.Workflow.Runtime Critical: 0 : Uncaught exception escaped to the root of the workflow.
        In instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 in activity
    Inner exception: System.IO.FileNotFoundException: Could not load file or assembly 'LocalService_872316c48ccc438d88c3741a1a03695c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. File name: 'LocalService_872316c48ccc438d88c3741a1a03695c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(String assemblyString)
       at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
       at System.Runtime.Serialization.ObjectManager.DoFixups()
       at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
       at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter)
       at System.Workflow.ComponentModel.Activity.Clone()
       at System.Workflow.ComponentModel.ActivityExecutionContextManager.CreateExecutionContext(Activity activity)
       at System.Workflow.Activities.StateActivity.ExecuteChild(ActivityExecutionContext context, Activity childActivity)
       at System.Workflow.Activities.ExecuteChildStateAction.Execute(ActivityExecutionContext context)
       at System.Workflow.Activities.StateMachineExecutionState.ProcessActions(ActivityExecutionContext context)
       at System.Workflow.Activities.StateActivity.ExecuteRootState(ActivityExecutionContext context)
       at System.Workflow.Activities.StateActivity.Execute(ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.CompositeActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutionFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

    System.Workflow.Runtime Information: 0 : Workflow Runtime: WorkflowExecutor: Terminating instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent end: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteSetEndDate start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteSetEndDate end: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : TimerEventSubscriptionQueue: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 Suspend
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent start: 05/29/2007 03:25:16
    System.Workflow.Runtime.Hosting Information: 0 : SqlTrackingService.ExecuteRetried ExecuteInsertWorkflowInstanceEvent end: 05/29/2007 03:25:16
    System.Workflow.Runtime Information: 0 : Workflow Runtime: WorkflowExecutor: Calling SaveWorkflowInstanceState for instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 hc 28840036
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService(00000000-0000-0000-0000-000000000000):Committing instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, Blocked=0, Unlocked=True, NextTimer=12/31/9999 23:59:59
    System.Workflow.Runtime Information: 0 : pending work hc 60754125 added workItem hc 58729077
    System.Workflow.Runtime Information: 0 : Workflow Runtime: WorkflowExecutor: Calling CommitTransaction for instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 hc 28840036
    System.Workflow.Runtime.Hosting Information: 0 : AddToConnectionInfoTable 1 in table of count 1
    System.Workflow.Runtime Information: 0 : pending work hc 60754125 added workItem hc 58729077
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService(00000000-0000-0000-0000-000000000000): inserting instance: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, unlocking: True database: SharedStore
    System.Workflow.Runtime.Hosting Information: 0 : TransactionCompleted 1
    System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 : Done with running scheduled entry: SubscriptionEvent((1)EditorialWorkflow, ActivityStatusChange('(1)EditorialWorkflow', Faulting, Faulted))
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime:SchedulePersisted event raised for instance Id ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime:ScheduleTermination event raised for instance Id ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime::TryRemoveWorkflowExecutor, instance:ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, hc:28840036
    System.Workflow.Runtime.Hosting Information: 0 : WorkflowRuntime::_removeInstance, instance:ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, hc:28840036
    System.Workflow.Runtime Transfer: 0 : , relatedActivityId=00000000-0000-0000-0000-000000000000
    System.Workflow.Runtime.Hosting Information: 0 : ManualWorkflowSchedulerService: CanRun is False
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService OpenConnection start: 05/29/2007 03:25:18
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService. OpenConnection end: 05/29/2007 03:25:18
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService(00000000-0000-0000-0000-000000000000):Loading instance ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService(00000000-0000-0000-0000-000000000000): retreiving instance: ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0, database: SharedStore
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService.RetrieveStateFromDB ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 ExecuteReader start: 05/29/2007 03:25:18
    System.Workflow.Runtime.Hosting Information: 0 : SqlWorkflowPersistenceService.RetrieveStateFromDB ec6d6cc9-9aa6-4439-ac7a-08e590cc39d0 ExecuteReader end: 05/29/2007 03:25:18

     


    Wednesday, May 30, 2007 1:29 AM
  • Add an AppDomain assembly resolver where you are starting the workflow runtime, like the following, so that you can return the assembly that can be found:

     

    Code Snippet

    AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)

    {

        Assembly resolvedAssembly = null;

     

        //  If it is a type you know about return the assembly

        if (args.Name.Equals(this.GetType().Assembly.FullName))

        {

            resolvedAssembly = this.GetType().Assembly;

        }

     

        return resolvedAssembly;

    };

     

    Wednesday, May 30, 2007 3:11 AM
  • thx tom, i'll try

    can you explain this?

    why in the xaml activation case, there are duplicated workflowtypes in the database

    Wednesday, May 30, 2007 3:35 AM
  • Mirricle,

     

    - to your question about the duplicated workflowtypes - see this thread

     

    - Note, the workflowdefinition is cached based on the calculated hash value from the xoml stream, if this xomlHasCode is not found in the cache, the new workflowdefinition is created. Therefore, if your xoml file has been changed (for instance, you add more whitespaces), the WorkflowRuntime will handle this xoml as a new definition.

     

     

    Thanks

     

    Roman

     

    Wednesday, May 30, 2007 3:54 AM
  • but i didn't, there's only one xoml file, and i used it readonly
    Wednesday, May 30, 2007 4:17 AM