• Kentico There is already an open DataReader associated with this Command which must be closed first.


    System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
    at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
    at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
    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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    at CMS.DataEngine.AbstractDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
    at CMS.DataEngine.GeneralConnection.RunQuery(QueryParameters query)
    at CMS.DataEngine.GeneralConnection.RunQueryWithRetry(QueryParameters query, Int32 retryCount)
    at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query, Int32& totalRecords)
    at CMS.DataEngine.DataQueryBase`1.GetDataFromDBInternal()
    at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
    at CMS.DataEngine.DataQueryBase`1.GetData()
    at CMS.DataEngine.DataQueryBase`1.get_Result()
    at CMS.DataEngine.ObjectQueryBase`2.GetResults(IDataQuery query, Int32& totalRecords)
    at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
    at CMS.DataEngine.DataQueryBase`1.GetData()
    at CMS.DataEngine.ObjectQueryBase`2.GetData()
    at CMS.DataEngine.DataQueryBase`1.get_Result()
    at CMS.DataEngine.ObjectQueryBase`2.EnsureTypedResult()
    at CMS.DataEngine.ObjectQueryBase`2.System.Collections.IEnumerable.GetEnumerator()
    at CMS.DataEngine.EnumerableWrapper`1.-GetEnumerator>d__5.MoveNext()
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
    at System.Linq.EnumerableExecutor`1.ExecuteBoxed()
    at CMS.DataEngine.CMSQueryProvider`1.Execute[TResult](Expression expression)
    at CMS.DataEngine.AbstractInfoProvider`3.GetInfoByFullNameInternal(String fullName)
    at CMS.DataEngine.AbstractInfoProvider`3.GetInfoByFullName(String fullName, Boolean useHashtable)
    at CMS.DataEngine.QueryInfoProvider.GetQueryInfoInternal(String queryName)
    at CMS.DataEngine.QueryInfoProvider.GetQueryInfo(String name, Boolean throwException)
    at CMS.DataEngine.QueryInfoProvider.QueryIsExplicitlyDefined(String className, String queryName)
    at CMS.DataEngine.SimpleDataClass.Insert(Boolean initId)
    at CMS.DataEngine.AbstractInfoBase`1.InsertData()
    at CMS.CustomTables.CustomTableItem.InsertData()
    at CMS.DataEngine.AbstractInfoProvider`3.SetInfo(TInfo info)

    It seems that your using your own custom table they set up: Managing custom tables and are trying to use the insert method from the API: Custom table data.

    Can you debug the code to see if it's your custom code that is throwing the error? And If you are creating multiple threads in the code, I've seen examples such as new CMSThread(() => { Sender … }) and Task.Factory.StartNew(CMSThread.Wrap(() =>{// Custom code...})); solved it for previous customer with this error.

    Custom code review falls outside of regular Kentico maintenance. If you need assistance with your custom implementation or would like a hands-on review of best practices, I recommend that you consider our paid Consulting services. Kentico Solution Architects will be able to offer you 1-on-1 assistance with detailed explanations.

    按照这个修改

     Task.Factory.StartNew(CMSThread.Wrap(() =>
                        {
                          //Custom code
                        }));

    https://docs.xperience.io/k12sp/installation/hotfix-instructions-kentico-12

    12.0.73

    • API – After applying the hotfix, the static contexts in the Kentico API, such as SiteContext, ContactManagementContext, or CMSActionContext persist their values within custom asynchronous code (async methods). The changes may in certain cases cause incorrect behavior or exceptions when using the TaskFactory API in custom code. To avoid the issues, enclose the code within an additional call of the CMSThread.Wrap method:

       
    using CMS.Base;
    
    Task.Factory.StartNew(CMSThread.Wrap(() =>
    {
        // Custom code
        ...
    }));
  • 相关阅读:
    mkconfig文件里的"cat << EOF >> config.h"
    (ARM v7)信号量、互斥体代码追踪
    (ARM v7)自旋锁、读写锁、顺序锁代码追踪
    mac 系统上安装navicat
    git2consul配置管理工具使用教程
    Spring Cloud Feign如何上传文件
    spring-cloud feign的多参数传递方案
    Consul下载安装及运行教程
    比SecureCRT更好用的工具MobaXterm下载安装使用教程
    Linux下RocketMQ下载安装教程
  • 原文地址:https://www.cnblogs.com/chucklu/p/16426412.html
Copyright © 2020-2023  润新知