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
...
}));
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-06-30 Reporting Services Single Sign On (SSO) Authentication - Part 1
2020-06-30 .NET - WindowStyle = hidden vs. CreateNoWindow = true?
2020-06-30 WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)
2020-06-30 How to fix IIS website loading forever
2020-06-30 Cannot read configuration file due to insufficient permissions
2020-06-30 How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C#.NET
2020-06-30 What is the difference between Version and 'Runtime Version' in .Net?