locked
Plugin failures in MSDCRM RRS feed

  • Question

  • Hi,

    We have Asynchronous plugin on opportunity post update.

    This plugin fails randomly with exception message "Context is not initialized or already cleaned up."

    Can you please help me to find out the root cause and fix the issue. please find the below exception details.

    Thanks..

    Error Message:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Context is not initialized or already cleaned up.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">0</d2p1:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <d2p1:key>SubErrorCode</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>Context is not initialized or already cleaned up.</Message>
      <Timestamp>2017-01-11T01:16:35.1202096Z</Timestamp>
      <ExceptionSource>PluginExecution</ExceptionSource>
      <InnerFault i:nil="true" />
      <OriginalException>Microsoft.Xrm.Sdk.InvalidPluginExecutionException
       at OtisChina.Process.Project.ProjectPost.Validate()
       at OtisChina.Process.BasePlugIn.Execute(IServiceProvider serviceProvider)
       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass5.&lt;Execute&gt;b__0()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)
       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)
       at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
      <TraceText>



    </TraceText>
    </OrganizationServiceFault>

    Wednesday, January 11, 2017 1:30 AM

All replies

  • Hello,

    Please share your plugin code for here. Looks like context is being nullified at some point in your code.


    Jugal Kishore Dandamudi.

    Wednesday, January 11, 2017 10:30 AM
  • One possible cause is if you use a class-level variable to store the plugin context (IPluginExecutionContext or one of its properties ). You have no control other the lifecycle of class-level variables, so shouldn't use these within a plugin (or should only use them for invariant data, and always check if they are still valid)

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, January 11, 2017 11:46 AM
    Moderator