locked
Persistence exception in workflow assembly RRS feed

  • Question

  • Hi,

    my workflow contains three steps:

    - the extension "General Utilities: Who Am I" to return the executing user, if triggered manually

    - running a custom workflow activity, which creates and disables some records related to a marketing list

    - sending en e-mail to executing user with results of my workflow activity

    Error message in trace file is:

    at WorkflowHost.OnWorkflowTerminated(Object sender, WorkflowTerminatedEventArgs args) at WorkflowRuntime.OnScheduleTerminated(WorkflowExecutor schedule, WorkflowTerminatedEventArgs args) at WorkflowRuntime.WorkflowExecutionEvent(Object sender, WorkflowExecutionEventArgs e) at EventHandler`1.Invoke(Object sender, TEventArgs e) at WorkflowExecutor.FireWorkflowTerminated(Exception exception) at SchedulerLockGuard.FireEvents(List`1 eventList, WorkflowExecutor workflowExec) at SchedulerLockGuard.Dispose() at WorkflowExecutor.RunSome(Object ignored) at WorkItem.Invoke(WorkflowSchedulerService service) at DefaultWorkflowSchedulerService.QueueWorkerProcess(Object state) at _ThreadPoolWaitCallback.WaitCallback_Context(Object state) at ExecutionContext.runTryCode(Object userData) at RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at _ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack) at _ThreadPoolWaitCallback.PerformWaitCallback(Object state)

    >Workflow terminated: {45640C66-1601-E011-B3E5-0050569706CB} - System.Workflow.Runtime.Hosting.PersistenceException: Der Typ "Microsoft.Crm.Asynchronous.SdkTypeProxyCrmServiceWrapper" in Assembly "CrmAsyncService, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ist nicht als serialisierbar gekennzeichnet. ---> System.Runtime.Serialization.SerializationException: Der Typ "Microsoft.Crm.Asynchronous.SdkTypeProxyCrmServiceWrapper" in Assembly "CrmAsyncService, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ist nicht als serialisierbar gekennzeichnet.

    bei System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) bei System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) bei System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() bei System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) bei System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) bei System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) bei System.Workflow.ComponentModel.Activity.Save(Stream stream, IFormatter formatter) bei System.Workflow.ComponentModel.Activity.Save(Stream stream) bei System.Workflow.Runtime.Hosting.WorkflowPersistenceService.GetDefaultSerializedForm(Activity activity) bei Microsoft.Crm.Workflow.CrmWorkflowPersistenceService.SaveWorkflowInstanceState(Activity rootActivity, Boolean unlock) bei System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation) --- Ende der internen Ausnahmestapelüberwachung --- bei System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation) bei System.Workflow.Runtime.WorkflowExecutor.System.Workflow.ComponentModel.IWorkflowCoreRuntime.PersistInstanceState(Activity activity) bei System.Workflow.ComponentModel.Activity.MarkClosed() bei System.Workflow.ComponentModel.Activity.MarkCompleted() bei System.Workflow.ComponentModel.ActivityExecutionContext.CloseActivity() bei System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) bei System.Workflow.Runtime.Scheduler.Run()

     

    My Code (removed some business logic):

    Option Compare Text
    
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections.Generic
    Imports System.ComponentModel
    Imports System.ComponentModel.Design
    Imports System.Text
    Imports System.Workflow.ComponentModel.Compiler
    Imports System.Workflow.ComponentModel.Serialization
    Imports System.Workflow.ComponentModel
    Imports System.Workflow.ComponentModel.Design
    Imports System.Workflow.Runtime
    Imports System.Workflow.Activities
    Imports System.Workflow.Activities.Rules
    
    Imports System.IO
    
    ' Microsoft Dynamics CRM namespaces
    Imports Microsoft.Crm.Sdk
    Imports Microsoft.Crm.Sdk.Query
    Imports Microsoft.Crm.SdkTypeProxy
    Imports Microsoft.Crm.Workflow
    Imports Microsoft.Crm.Workflow.Activities
    
    Namespace CustomWorkflowActivity
      <CrmWorkflowActivity("Teilnehmer mit Listen abgleichen", "Veranstaltung")> _
      Public Class ListToAttendees
        Inherits SequenceActivity
    
        Private Const STATUS_FROM_LIST As Integer = 5
    
        Dim CRM As ICrmService
        Dim datCurrentSync As Date
    
        Dim strWFOutput As New List(Of String)
        Dim strDebugOutput As New List(Of String)
    
        Protected Overrides Function Execute(ByVal executionContext As ActivityExecutionContext) As ActivityExecutionStatus
          Try
            ' Get access to the Microsoft Dynamics CRM Web service proxy.
            Dim contextService As IContextService = CType(executionContext.GetService(GetType(IContextService)), IContextService)
            Dim context As IWorkflowContext = contextService.Context
    
            Dim crmService As ICrmService = context.CreateCrmService()
            CRM = crmService
    
            ' TODO: Workflow activity business logic goes here.
            Return SyncAttendees(context.PrimaryEntityId)
    
          Catch ex As System.Web.Services.Protocols.SoapException
            Throw New InvalidPluginExecutionException(String.Format("An error occurred in the {0} plug-in.", Me.GetType().ToString()), ex)
    
            Return ActivityExecutionStatus.Faulting
          End Try
    
          Return ActivityExecutionStatus.Closed
        End Function
    
        Public Shared WFOutputProperty As DependencyProperty = DependencyProperty.Register("WFOutput", GetType(String), GetType(ListToAttendees))
    
        <CrmOutput("WFoutput")> _
        Public Property WFOutput() As String
          Get
            Return CType(Me.GetValue(WFOutputProperty), String)
          End Get
    
          Set(ByVal value As String)
            Me.SetValue(WFOutputProperty, value)
          End Set
        End Property
    
    #Region "Workflow Logik"
    
        Private Function SyncAttendees(ByVal EventGUID As Guid) As ActivityExecutionStatus
          ...removed...
    	End Function
    #End Region 'Workflow Logik
    
      End Class
    End Namespace
    
    

    Thing is: the above error does only occur when I add the e-mail step (or another like creating some random record). Workflow containing only "Who Am I" plus my workflow activity does not throw an error.

    Since I'm not a NET pro, I have no idea where to start investigating this, given the fact that the assembly itself does work correctly.

     

    Thanks

    Tuesday, December 7, 2010 3:56 PM

Answers

  • Just an FYI first up; this would probably be more appropriately placed in the CRM Development forum.

    The error message contains the text "ist nicht als serialisierbar gekennzeichnet" which translates as "is not marked as serializable".  I'm going to guess that you only see the error when you use a subsequent Workflow step due to accessing the output property (WFOutput) from the errant Workflow Activity.  I'm guessing (again) that the CRM has to serialise the Workflow Activity assembly in order to use the output property in subsequent steps.

    My VB is *very* rusty, but I think the issue may be with your "caching" the ICRMService reference in the following object variable:

     Dim CRM As ICrmService

    Instead of using an object property, try passing the ICRMService variable from the Execute method to your SyncAttendees method, thus:

    Private Function SyncAttendees(crmService As ICrmService, ByVal EventGUID As Guid) As ActivityExecutionStatus
       ...removed...
    End Function
    
    

    --pogo (pat)
    • Marked as answer by Matzer J Friday, December 10, 2010 10:24 AM
    Tuesday, December 7, 2010 11:29 PM

All replies

  • Just an FYI first up; this would probably be more appropriately placed in the CRM Development forum.

    The error message contains the text "ist nicht als serialisierbar gekennzeichnet" which translates as "is not marked as serializable".  I'm going to guess that you only see the error when you use a subsequent Workflow step due to accessing the output property (WFOutput) from the errant Workflow Activity.  I'm guessing (again) that the CRM has to serialise the Workflow Activity assembly in order to use the output property in subsequent steps.

    My VB is *very* rusty, but I think the issue may be with your "caching" the ICRMService reference in the following object variable:

     Dim CRM As ICrmService

    Instead of using an object property, try passing the ICRMService variable from the Execute method to your SyncAttendees method, thus:

    Private Function SyncAttendees(crmService As ICrmService, ByVal EventGUID As Guid) As ActivityExecutionStatus
       ...removed...
    End Function
    
    

    --pogo (pat)
    • Marked as answer by Matzer J Friday, December 10, 2010 10:24 AM
    Tuesday, December 7, 2010 11:29 PM
  • Hi,

    I've changed my workflow code (old habits...) and pass the CRMService in every function now.

    Error is gone, thanks a lot :)

     

    Regards

     

    Sorry for mixing up development/deployment...

    Friday, December 10, 2010 10:24 AM