Friday, October 9, 2009

Workflow Issue & Solution

The solution for the workflow issue mentioned below is just restarting the Microsoft CRM Async Service.
This is because the strong key file has changed but it has not been effected in CRM system, thus it requires a Async service restart.

ErrorCode -2147201001

Workflow paused due to error: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Workflow.Runtime.Hosting.DefaultWorkflowLoaderService.CreateInstance(Type workflowType) at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity(Type workflowType, Boolean createDefinition, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowDefinitionDispenser.GetRootActivity(Type workflowType, Boolean createNew, Boolean initForRuntime) 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.GetWorkflowExecutor(Guid instanceId, CreationContext context) at System.Workflow.Runtime.WorkflowRuntime.InternalCreateWorkflow(CreationContext context, Guid instanceId) at System.Workflow.Runtime.WorkflowRuntime.CreateWorkflow(Type workflowType, Dictionary`2 namedArgumentValues, Guid instanceId) at Microsoft.Crm.Workflow.WorkflowHost.StartWorkflowFromType(Guid instanceId, Type workflowType, WorkflowContext context) Inner Exception: System.IO.FileLoadException: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Compiled.Workflowa09e92b8c5b4de11818d0800279388db.InitializeComponent() at Compiled.Workflowa09e92b8c5b4de11818d0800279388db..ctor()

Workflow Issue & Solution

The solution for the workflow issue mentioned at the end is as as follows
  1. Remove the existing strong name key file from the workflow assembly code.
  2. Add a new strong name key file.
  3. Compile the workflow assembly.
  4. Register the workflow assembly in database mode.
  5. Restart the CRM async service
ErrorCode - 2147201001

Workflow paused due to error: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Workflow.Runtime.Hosting.DefaultWorkflowLoaderService.CreateInstance(Type workflowType) at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity(Type workflowType, Boolean createDefinition, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowDefinitionDispenser.GetRootActivity(Type workflowType, Boolean createNew, Boolean initForRuntime) 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.GetWorkflowExecutor(Guid instanceId, CreationContext context) at System.Workflow.Runtime.WorkflowRuntime.InternalCreateWorkflow(CreationContext context, Guid instanceId) at System.Workflow.Runtime.WorkflowRuntime.CreateWorkflow(Type workflowType, Dictionary`2 namedArgumentValues, Guid instanceId) at Microsoft.Crm.Workflow.WorkflowHost.StartWorkflowFromType(Guid instanceId, Type workflowType, WorkflowContext context) Inner Exception: System.TypeLoadException: Could not load type 'M.C.Workflow.StartChildWorkflow' from assembly 'M.C.Workflow.SubscriptionWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=99c841002e45ae51'. at Compiled.Workflow9073d7dbc4b4de11818d0800279388db.InitializeComponent() at Compiled.Workflow9073d7dbc4b4de11818d0800279388db..ctor()