首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CodeFluent持久性竞赛条件

CodeFluent持久性竞赛条件
EN

Stack Overflow用户
提问于 2016-06-07 11:47:54
回答 1查看 109关注 0票数 0

一旦数据库因某种原因而变得缓慢(长时间运行的查询、备份、性能分析器)

我的Web应用程序开始收到以下错误:

代码语言:javascript
复制
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.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CodeFluent.Runtime.CodeFluentPersistence.InternalExecuteNonQuery(Boolean firstTry)
   at CodeFluent.Runtime.CodeFluentPersistence.InternalExecuteNonQuery(Boolean firstTry)
.... _> stack trace continues to my code


CodeFluent.Runtime.CodeFluentRuntimeException: CF1044: Nested persistence command is not supported. Current command: '[Contract_Search]', nested command: '[zref_template_document_LoadBlobFile]'.
   at CodeFluent.Runtime.CodeFluentPersistence.CreateStoredProcedureCommand(String schema, String package, String intraPackageName, String name)
   at CodeFluent.Runtime.BinaryServices.BinaryLargeObject.GetInputStream(CodeFluentContext context, Int64 rangeStart, Int64 rangeEnd)
.... _> stack trace continues to my code

当我打开两个浏览器窗口并执行不同的操作时,会发生第二个错误CF1044。在一个中搜索,在另一个中生成一个文档。

很难复制。事情从来都不是这样的。

有一个竞赛条件,,在某个地方,我不知道。

EN

回答 1

Stack Overflow用户

发布于 2016-06-10 11:50:26

以下是对我起作用的东西:

代码语言:javascript
复制
public byte[] GetRtfDocumentStreamBuffer(TemplateDocumentType templateType, int culture)
{
    var template = TemplateDocument.LoadActiveByDocumentTypeAndLcid(DateTime.Today, templateType.Id, culture);
    var resultStream = new MemoryStream();

    using (var cf = CodeFluentContext.GetNew(Constants.MyApplicationStoreName))
    using (var templateStream = template.File.GetInputStream(cf, 0, 0))
    using (var resultWriter = new StreamWriter(resultStream, Encoding.GetEncoding("windows-1252")))
    {
        GenerateRtfDocument(....);

        resultWriter.Flush();
    }

    return resultStream.GetBuffer();
}

我在反编译的cf运行时中看到的是CodeFluentContext.Dispose()调用CodeFluentPersistence.Dispose(),它关闭读取器并释放连接。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37678559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档