Skip to Content
author's profile photo Former Member
Former Member

"The process cannot access the file ..." occurs when export crystal report

We are using a web application developed in VS 2005, .NET 2.0 with the bundled Crystal Reports version 10.2.3600.0 running on a Windows 2003 Standard server with 4GB Ram and Dual CPU's. Periodically we are still receiving the following error in our production environment:

InnerException:

The process cannot access the file because it is being used by another process.

at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)

at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType)

This is occuring at the point on the code where the report is being exported to a PDF. Exporting the report to Excel does not appear to cause the error.

Stream outStream = report.ExportToStream(ExportFormatType.PortableDocFormat);

byte[] charStream = new byte[outStream.Length];

outStream.Read(charStream, 0, (int)outStream.Length);

if ((charStream != null) && (charStream.Length > 0))

{

HttpContext.Current.Response.ContentType = "application/pdf";

HttpContext.Current.Response.OutputStream.Write(charStream, 0, charStream.Length);

HttpContext.Current.Response.End();

}

report.Close();

report.Dispose();

ds.Dispose();

GC.Collect();

Closing and disposing of the report and dataset (xsd) are followed by a call for garbage collection. We are unable to produce the error in our development environmennt and have not at this point been unable to pinpoint a problematic report. The development team members do have SP1 installed. The report limit has not been changed from the standard of 75 jobs. Reviewed the following document, the-process-cannot-access-the-file--occurs-when-ex However this applies to VS 2008. Any suggestions to resolve the issue would be greatly appreciated.

Thanks,

Joe

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Dec 08, 2010 at 02:35 PM

    First I'd like you to confirm you are passing in an ADO .NET dataset. E.g.;

    crReportDocument.SetDataSource(dataSet)

    Next, I wonder about the loads being put on the report engine. You mention 75 print jobs indicating an awareness of some limits that the print engine has. In addition to a print job, there is also a 3 CPL (concurrent processor license). Meaning the print engine is limited to three processing requests, other requests are queued up.

    BTW., one process could use up 75+ print jobs Print job is defined as essentially any work the engine has to do; paging, drilling, zooming, etc. Additionally, a report with a subreport in a detail section that contains 75 records will use up 76 print jobs (75 subreports + main report).

    So, the question here, stemming from the periodical behavior is; what kind of loads are you putting on the print engine? How many users are submitting requests? How many reports are being run at the same time? Etc.

    Ludek

    Follow us on Twitter http://twitter.com/SAPCRNetSup

    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2010 at 03:57 AM

    Ludek,

    Thank you for the quick response. In regard to to your question regarding the use of datasets. Yes, all of the reports are passed an ADO .NET Dataset. Most reports are summary or detail using 1 or more datatables as a source. There are a few reports with sub-reports but if used it would be in the report footer and not the detail section. I reviewed a day that had heavier client activiy and counted approx. 100 reports being run throughout a 12 hour period. There is a potential for the same report to be selected by multiple users due to some reports being used for personnel scheduling and tracking purposes. (Our system does have importing/exporting of Hospital-based information) I should also mention that the database we are using is Progress OpenEdge Veresion 10.2A running on Unix. We using the Windows ODBC driver to access it.

    The statement, "there is also a 3 CPL (concurrent processor license). Meaning the print engine is limited to three processing requests, other requests are queued up. " Could you please clarify this a little more as I need to report the current limitations back to my superiors.

    • Is it correct to presume that the physical number of CPU's is not factored into the CPL? So that a Server with 2 or more processors does not increase the 3 concurrent requests? Therefore 2 CPU's would not increase the CPL limit to 6 processes?

    • What would be an alternate solution to this limit be, considering the report requests could increase significantly?

    I also have some questions regarding the Engine itself. We are currently experienceing periodic high memory usage which is causing the IIS process to hang and need a restart. I am trying to eliminate CR as a potential source of higher memory usage.

    • If only only 3 reports can be processed at the same time. If one or more of the reports currently processing is taking longer due to receiving large amounts of data, how does that affect the queue? And what is stored in the queue, data and/or the report? Is this something that could consume memory?

    • I have read in the documentation on this site, that the dataset sent to the engine is copied in memory during report construction. So if a large amount of data is requested for a report (as an example 10+ MB) Could enough users requesting reports drive the memory up because memory usage doubled due to the dataset?

    • Understanding the the CR DLL's are loaded on the first report request, do they get released at some point time due to inactivity or garbage collection? How much memory usage could be consumed when they load and stay resident?

    I appreciate your assistance, and look forward to your response.

    Thank you,

    Joe

    Add a comment
    10|10000 characters needed characters exceeded

    • Good morning Joe

      For more details re. loading please see the following resources:

      [Crystal Reports 2008 Component Engine Scalability|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/7025839b-00d4-2b10-33b4-cf0aa9e08412?quicklink=index&overridelayout=true]

      [How Can I Optimize Scalability?|http://msdn.microsoft.com/en-us/library/ms225519.aspx]

      [Choosing the Right Business Objects SDK for Your Needs|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40bccdfd-88a6-2b10-1da1-c47a54b625a7]

      To answer your questions:

      • Is it correct to presume that the physical number of CPU's is not factored into the CPL? So that a Server with 2 or more processors does not increase the 3 concurrent requests? Therefore 2 CPU's would not increase the CPL limit to 6 processes?

      - Server with 2 or more processors does not increase the 3 concurrent requests.

      • What would be an alternate solution to this limit be, considering the report requests could increase significantly?

      - Only way around this would be to web farm the solution

      • If only only 3 reports can be processed at the same time. If one or more of the reports currently processing is taking longer due to receiving large amounts of data, how does that affect the queue? And what is stored in the queue, data and/or the report? Is this something that could consume memory?

      - The report can take as much time as it needs. The result is that one license will not be released until the report is done. There is no data stored, just a pointer to the report. However queued apps will chew up memory, some times to the point of the server becoming unresponsive

      • I have read in the documentation on this site, that the dataset sent to the engine is copied in memory during report construction. So if a large amount of data is requested for a report (as an example 10+ MB) Could enough users requesting reports drive the memory up because memory usage doubled due to the dataset?

      - Absolutely. See [Crystal Reports Guide to ADO.NET|http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/401c4455-a31d-2b10-ae96-fa57af5aec20].

      • Understanding the the CR DLL's are loaded on the first report request, do they get released at some point time due to inactivity or garbage collection? How much memory usage could be consumed when they load and stay resident?

      - No they do not. Not as long as the application is running.

      Ludek

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.