locked
Weird exception in Workflow Custom Activity RRS feed

  • Question

  • Sometimes I get this exception:

    System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #5550C463

    And it leaves workflow in status "Waiting" but usually everything works and if I run later the same workflow against that record it will not throw an exception


    Wednesday, July 12, 2017 7:08 AM

All replies

  • Sergey,

    Under Process Progress there is "Details" section. Can you please expand it and either post a screenshot here or copy-paste content of that error? Like shown on the following screenshot:


    Dynamics CRM/Business Solutions MVP
    Read My blog

    Wednesday, July 12, 2017 1:49 PM
    Moderator
  • This is another similar exception. I get 3-5 each day

    Message:

    System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #8ABA3CDC

    Error Message:

    Unhandled Exception: Microsoft.Crm.CrmException: System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #8ABA3CDC
       at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
       at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)


    Thursday, July 13, 2017 6:37 AM
  • Hello Sergey,

    are you calling any custom workflow activity from the OOB Workflow. 

    Thanks, 

    Viswa


    Vish

    Thursday, July 13, 2017 11:52 AM
  • That's weird. Can you share code of your custom workflow activity?

    Dynamics CRM/Business Solutions MVP
    Read My blog

    Thursday, July 13, 2017 12:58 PM
    Moderator
  • No, I have created my own workflow and use my custom workflow activity inside it.

    Andrii, do you want whole solution or just piece of it?

    Friday, July 14, 2017 9:16 AM
  • This is call stack

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #A746A765Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ActivityId>93e55b39-231b-4640-a971-10ecb35baaf5</ActivityId>
      <ErrorCode>-2147220970</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #A746A765</Message>
      <Timestamp>2017-07-17T13:03:48.2140927Z</Timestamp>
      <ExceptionRetriable>false</ExceptionRetriable>
      <ExceptionSource>PluginExecution</ExceptionSource>
      <InnerFault i:nil="true" />
      <OriginalException>System.Security.SecurityException
       at System.ComponentModel.Win32Exception.GetObjectData(SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectCloneHelper.GetObjectData(Object serObj, String&amp; typeName, String&amp; assemName, String[]&amp; fieldNames, Object[]&amp; fieldValues)


       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain)
       at Microsoft.Crm.Sandbox.SandboxWorker.ExecuteCustomWorkflowActivity(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteCustomWorkflowActivityAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String assemblyContents, Boolean returnTraceInfo)
       at Microsoft.Crm.Sandbox.SandboxCustomActivity.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)
       at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

    Monday, July 17, 2017 4:28 PM
  • Sergey,

    I already posted - can you please post sourcecode of your custom workflow activity?


    Dynamics CRM/Business Solutions MVP
    Read My blog

    Monday, July 17, 2017 4:47 PM
    Moderator
  • Any update on this?

    Dynamics CRM/Business Solutions MVP
    Read My blog

    Wednesday, July 19, 2017 1:53 PM
    Moderator
  • System.Security.SecurityException is indicating that your custom code is trying to access resources that are not allowed to be accessed in sandbox mode or it is violating any other sandbox restrictions. 

    Refer to this link Plug-in isolation, trusts, and statistics.

    Since you said that the exception is not being thrown every time, there may be any conditional check around the code that is violating the restrictions. 

    If you have Dynamics 365/CRM on premises version, there may be chances where the platform is killing the sandbox worker process because it is exceeding certain limits as described in the link:

    Microsoft Dynamics 365 collects run-time statistics and monitors plug-ins and custom workflow activities that execute in the sandbox. If the sandbox worker process that hosts this custom code exceeds threshold CPU, memory, or handle limits or is otherwise unresponsive, that process will be killed by the platform. At that point any currently executing plug-in or custom workflow activity in that worker process will fail with exceptions. However, the next time that the plug-in or custom workflow activity is executed it will run normally. There is one worker process per organization so failures in one organization will not affect another organization.


    blog: http://technologynotesforyou.wordpress.com

    Wednesday, July 19, 2017 7:14 PM
  • I am not sure why this issue is appearing however I have also observed it. If you are checking the regarding as case then this error will not appear when the it is regarded with a case but this error appears when it is regarded with any other entity. If you put a branch condition of regarding with organisations then this error will not appear for case and organisation.

    Therefore you might have to add entities in the condition with blank actions.


    Regards Faisal

    Tuesday, July 25, 2017 8:25 AM
  • Hi Andreii,

    Unfortunately I can't post the whole solution but can post entry point class (inherited from CodeActivity) if it will make sense...


    Friday, August 4, 2017 10:18 AM
  • Sergiy,

    Let's try that.


    Dynamics CRM/Business Solutions MVP
    Read My blog

    Friday, August 4, 2017 11:31 AM
    Moderator
  • I have a guess that it could be a problem of access conflict as error message implies. I mean that the record is accessed by two sources (two workflows or a internal process of crm and my workflow), something like object locking. Could it be? Because I noticed that the problem happens when audit says there was an update event of the record immediately after the record was created and  my workflow triggers on created event. That update event made by system and changed the description field, I have no idea why but seems this update event and my workflow could conflict with each other.
    Thursday, August 17, 2017 10:19 AM
  • Sergey,

    It could be anything. Unfortunately I can't help more without sourcecode posted.


    Dynamics CRM/Business Solutions MVP
    Read My blog

    Thursday, August 17, 2017 10:38 AM
    Moderator