You are viewing limited content. For full access, please sign in.

Question

Question

The operation cannot be completed because the DbContext has been disposed.

asked on October 14

This morning, about 100 Forms instances terminated/suspended in our production environment. I am still working through the error log in Forms, but found this one and was wondering if anyone knows what it means?

Log Name:      Laserfiche-Forms-App/Admin
Source:        Laserfiche-Forms-App
Date:          10/14/2025 7:49:58 AM
Event ID:      10502
Task Category: UnexpectedErrorErrorAdmin
Level:         Error
Keywords:      Session0,Session1,Session2,Session3
User:          XXXX
Computer:      XXXX
Description:
An unexpected error has occurred. [LFF502-UnexpectedError]

Details:
URL: 
Error: UnexpectedError
Date: 10/14/2025 7:49:58 AM (US Mountain Standard Time)
HTTP Status Code: 500
Business Process ID: 0
Business Process Name: 

Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: An unexpected error has occurred. [LFF502-UnexpectedError]


Inner exception: System.InvalidOperationException
Message: The operation cannot be completed because the DbContext has been disposed.
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
   at Laserfiche.Forms.Routing.RoutingContextService.GetSingleUserSnapshotById(Int32 id)
   at Laserfiche.Forms.Routing.FlowObject.UpdateEndStatus(cf_bp_worker_instances processInstance, IRoutingContext routingContext, String endingStatus, Nullable`1 userId, Boolean isAllCompleted)
   at Laserfiche.Forms.Routing.RoutingDispatcher.HandleExecutionException(Exception ex, KeyValuePair`2 currentStep, Exception& executionException)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteStep(KeyValuePair`2 currentStep, Exception& executionException)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteSteps(Int32 processWorkerInstanceId, ActionType action, Int32 stepIdToAct, String comment, CancellationToken cancellationToken)
   at Laserfiche.Forms.Routing.RoutingDispatcher.RunProcess(Int32 currentStepId, Int32 processId, Int32 boundaryEventStepId, SubmissionDataSet inputData, Int32 refMainProcessInstanceId, Int32 lastSubmissionId, PaymentParams paymentParams, CancellationToken cancellationToken, AuditEventInfo auditEventInfo)
   at Laserfiche.Forms.Routing.InstanceProcessingService.RunRouting(RoutingRequestParameters requestParam)
   at Laserfiche.Forms.Routing.InstanceProcessingService.<>c__DisplayClass9_0.<StartRouting_Async>b__0()


Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Laserfiche-Forms-App" Guid="{98141CA4-660B-51C6-66B4-EC37F5B2FD87}" />
    <EventID>10502</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>55032</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000f00000000000</Keywords>
    <TimeCreated SystemTime="2025-10-14T14:49:58.869272200Z" />
    <EventRecordID>196772</EventRecordID>
    <Correlation />
    <Execution ProcessID="3116" ThreadID="11180" />
    <Channel>Laserfiche-Forms-App/Admin</Channel>
    <Computer>XXXX</Computer>
    <Security UserID="XXXX" />
  </System>
  <EventData>
    <Data Name="message">An unexpected error has occurred. [LFF502-UnexpectedError]

Details:
URL: 
Error: UnexpectedError
Date: 10/14/2025 7:49:58 AM (US Mountain Standard Time)
HTTP Status Code: 500
Business Process ID: 0
Business Process Name: 

Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: An unexpected error has occurred. [LFF502-UnexpectedError]


Inner exception: System.InvalidOperationException
Message: The operation cannot be completed because the DbContext has been disposed.
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
   at Laserfiche.Forms.Routing.RoutingContextService.GetSingleUserSnapshotById(Int32 id)
   at Laserfiche.Forms.Routing.FlowObject.UpdateEndStatus(cf_bp_worker_instances processInstance, IRoutingContext routingContext, String endingStatus, Nullable`1 userId, Boolean isAllCompleted)
   at Laserfiche.Forms.Routing.RoutingDispatcher.HandleExecutionException(Exception ex, KeyValuePair`2 currentStep, Exception&amp; executionException)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteStep(KeyValuePair`2 currentStep, Exception&amp; executionException)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteSteps(Int32 processWorkerInstanceId, ActionType action, Int32 stepIdToAct, String comment, CancellationToken cancellationToken)
   at Laserfiche.Forms.Routing.RoutingDispatcher.RunProcess(Int32 currentStepId, Int32 processId, Int32 boundaryEventStepId, SubmissionDataSet inputData, Int32 refMainProcessInstanceId, Int32 lastSubmissionId, PaymentParams paymentParams, CancellationToken cancellationToken, AuditEventInfo auditEventInfo)
   at Laserfiche.Forms.Routing.InstanceProcessingService.RunRouting(RoutingRequestParameters requestParam)
   at Laserfiche.Forms.Routing.InstanceProcessingService.&lt;&gt;c__DisplayClass9_0.&lt;StartRouting_Async&gt;b__0()

</Data>
  </EventData>
</Event>

 

0 0

Replies

replied on October 14

The error indicates that the Routing Engine was unable to commit changes to the SQL Server at that moment, which caused the instance execution to get stuck at termination. I'm not certain about the root cause. Were there any other errors in the logs? You might consider enabling debug log on the Forms Configuration page and reviewing the debug logs under C:\ProgramData\Laserfiche\Forms\logs. Hopefully, the logs will provide more detailed information.

0 0
replied on October 15

Yes, I was able to find the following error shortly before the one I posted above.

Log Name:      Laserfiche-Forms-App/Admin
Source:        Laserfiche-Forms-App
Date:          10/14/2025 7:49:58 AM
Event ID:      10018
Task Category: EntityFrameworkInaccessibleErrorAdmin
Level:         Error
Keywords:      Session0,Session1,Session2,Session3
User:          XXXX
Computer:      XXXX
Description:
Entity Framework returned the following error when trying to communicate with SQL Server: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.. [LFF18-EntityFrameworkInaccessible]

Details:
URL: 
Error: EntityFrameworkInaccessible
Date: 10/14/2025 7:49:58 AM (US Mountain Standard Time)
HTTP Status Code: 500
Business Process ID: 0
Business Process Name: 

Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: Entity Framework returned the following error when trying to communicate with SQL Server: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.. [LFF18-EntityFrameworkInaccessible]


Inner exception: System.Data.Entity.Infrastructure.RetryLimitExceededException
Message: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at Laserfiche.Forms.EntityModels.EntityContext.Commit(Int32 retryCount)
   at Laserfiche.Forms.Routing.StartEvent.InitializeDataForNewMainProcessInstance(Int32 instanceId, IRoutingContext routingContext)
   at Laserfiche.Forms.Routing.StartEvent.Execute(Int32 instanceId, IRoutingContext routingContext)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteStep(KeyValuePair`2 currentStep, Exception& executionException)

Inner exception: System.Data.Entity.Core.UpdateException
Message: An error occurred while updating the entries. See the inner exception for details.
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)

Inner exception: System.Data.SqlClient.SqlException
Message: Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Operation cancelled by user.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()

Inner exception: System.ComponentModel.Win32Exception
Message: The wait operation timed out



Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Laserfiche-Forms-App" Guid="{98141CA4-660B-51C6-66B4-EC37F5B2FD87}" />
    <EventID>10018</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>55516</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000f00000000000</Keywords>
    <TimeCreated SystemTime="2025-10-14T14:49:58.528537400Z" />
    <EventRecordID>196770</EventRecordID>
    <Correlation />
    <Execution ProcessID="3116" ThreadID="11180" />
    <Channel>Laserfiche-Forms-App/Admin</Channel>
    <Computer>XXXX</Computer>
    <Security UserID="XXXX" />
  </System>
  <EventData>
    <Data Name="message">Entity Framework returned the following error when trying to communicate with SQL Server: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.. [LFF18-EntityFrameworkInaccessible]

Details:
URL: 
Error: EntityFrameworkInaccessible
Date: 10/14/2025 7:49:58 AM (US Mountain Standard Time)
HTTP Status Code: 500
Business Process ID: 0
Business Process Name: 

Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: Entity Framework returned the following error when trying to communicate with SQL Server: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.. [LFF18-EntityFrameworkInaccessible]


Inner exception: System.Data.Entity.Infrastructure.RetryLimitExceededException
Message: Maximum number of retries (5) exceeded while executing database operations with 'SqlAzureRetryExecutionStrategy'. See inner exception for the most recent failure.
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at Laserfiche.Forms.EntityModels.EntityContext.Commit(Int32 retryCount)
   at Laserfiche.Forms.Routing.StartEvent.InitializeDataForNewMainProcessInstance(Int32 instanceId, IRoutingContext routingContext)
   at Laserfiche.Forms.Routing.StartEvent.Execute(Int32 instanceId, IRoutingContext routingContext)
   at Laserfiche.Forms.Routing.RoutingDispatcher.ExecuteStep(KeyValuePair`2 currentStep, Exception&amp; executionException)

Inner exception: System.Data.Entity.Core.UpdateException
Message: An error occurred while updating the entries. See the inner exception for details.
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)

Inner exception: System.Data.SqlClient.SqlException
Message: Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Operation cancelled by user.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()

Inner exception: System.ComponentModel.Win32Exception
Message: The wait operation timed out


</Data>
  </EventData>
</Event>

 

0 0
replied on October 16

Thank you for providing additional information. These errors occur when the Routing Engine attempts to communicate with the SQL Server but eventually times out after all retry attempts are exhausted. This may happen when the Routing Engine is under heavy load. To help with investigation, you can monitor the CPU and memory usage of the Routing Engine Service when termination happens.

A recommended solution is to upgrade to the latest release of Forms, where instances are no longer terminated due to EntityFrameworkInaccessible errors. For user tasks that have already been terminated, you can restart them to resume processing.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.