找回密码
 立即注册

QQ登录

只需一步,快速开始

wiljone

注册会员

12

主题

41

帖子

149

积分

注册会员

积分
149
wiljone
注册会员   /  发表于:2019-12-25 15:23  /   查看:3573  /  回复:1
1金币
本帖最后由 wiljone 于 2019-12-25 15:30 编辑

  var exporter = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
  var ReportPath = OriginalReportPath;
  GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(ReportPath));
  rpt.Report.DataSources[0].ConnectionProperties.ConnectString =     System.Configuration.ConfigurationManager.ConnectionStrings["SQLConn"].ConnectionString;

  rpt.Report.ReportParameters[0].DefaultValue.Values.Add(tax_id);
  rpt.Report.ReportParameters[1].DefaultValue.Values.Add(dns.Tables[0].Rows["ifa03c"].ToString());
  rpt.Report.ReportParameters[2].DefaultValue.Values.Add(dns.Tables[0].Rows["ifa04c"].ToString());

  var path = System.Web.Hosting.HostingEnvironment.MapPath("~/") + "
时分秒+帐号 + ".Pdf";//---
这里会加上指定时间后(如:时分秒) 才继续执行以下程序
//----
   exporter.Export(rpt.Document, path);
   rpt.Dispose();
   exporter.Dispose();

只有1个人产生PDF时,没有任何问题,但2个人在「同时同分同秒」产生PDF时,会产生错误「An item with the same key has already been added.」
在exporter.Export(rpt.Document, path)  这一段;

请问这个要如何解决?

详细错误讯息:
GrapeCity.ActiveReports.ReportException: An unexpected error occurred. Additional information: 'An item with the same key has already been added.' ---> System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)   at GrapeCity.ActiveReports.Expressions.Remote.LoaderProxy.#pR1(CustomCode customCode, List`1 modules)   at GrapeCity.ActiveReports.Expressions.Remote.LoaderProxy.Compile(CustomCode customCode)   at #cxA.#wc0.Build(IAppDomainBuilder appDomainBuilder, CustomCode customCode, IInstanceFactory instanceFactory)   at #DAA.#zc0.Build(PageReport pageReport, IAppDomainBuilder appDomainBuilder, Parameters parameters)   at GrapeCity.ActiveReports.ReportEval.<>c__DisplayClass5.#MO0()   at GrapeCity.ActiveReports.ReportEval.EvaluationContext..ctor(PageReport pageReport, #U9m options)   at GrapeCity.ActiveReports.ReportEval.#ZSZ(PageReport pageReport, #U9m options)   at GrapeCity.ActiveReports.ReportEval.#ZSZ(PageReport pageReport, Parameters parameters)   at #Uj1.#aTZ.get_EvaluationContext()   at #Uj1.#aTZ.<.ctor>b__4()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportParameters.ParameterInfo.get_EvaluationContext()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportParameters.ParameterInfo.Evaluate(ExpressionInfo expression)   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportParameters.ParameterInfo.#2j1(Parameter parameter)   at GrapeCity.ActiveReports.Expressions.ExpressionObjectModel.Parameter.#Ykf()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportParameters.ReportParametersProvider.#xEf()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportParameters.ReportParametersProvider.get_Parameters()   at #Uj1.#aTZ.#DEf()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportProcessor.#Tol()   at GrapeCity.ActiveReports.ReportsCore.Rendering.ReportProcessor.#fn(Boolean forceDataRefresh, Boolean forceParameterDataRefresh)   at GrapeCity.ActiveReports.Document.PageDocument.#0Kf(Boolean forceDataRefresh, Boolean forceParameterDataRefresh)   --- End of inner exception stack trace ---   at GrapeCity.ActiveReports.Document.PageDocument.#0Kf(Boolean forceDataRefresh, Boolean forceParameterDataRefresh)   at GrapeCity.ActiveReports.Document.PageDocument.Render(IRenderingExtension renderingExtension, StreamProvider streams, NameValueCollection settings, Boolean forceDataRefresh, Boolean forceParameterDataRefresh)   at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(PageDocument document, Stream stream, String pageRange)   at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(PageDocument document, String filePath, String pageRange)   at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(PageDocument document, String filePath)   











1 个回复

倒序浏览
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2019-12-25 16:24:25
沙发
这个是多线程的问题,同时执行,导致导出报错。这个可能需要你做 一个异步的操作
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部