The process cannot access the file 'X:\...\Data.dat' because it is being used

Posted by: leandro.oguro on 16 May 2018, 7:24 am EST

    • Post Options:
    • Link

    Posted 16 May 2018, 7:24 am EST

    Hello,

    I currently have a license for ActiveReport v3 and am evaluating existing projects to see if upgrading to v12 would be worth it (performance wise), however, when I try to generate multiple PDFs in parallel I start getting the following error:

    System.ComponentModel.LicenseException: The process cannot access the file ‘X:.…{GUID}{Number}\Data.dat’ because it is being used by another process.

    Is it because I’m using the trial version? If so, is there any way to circumvent that? I wanted to test the performance in parallel to compare with version 3 but with this error looks like it’s not going to be possible.

    Thanks in advance

  • Posted 16 May 2018, 10:43 pm EST

    Hello leandro,

    I am not able to reproduce the problem at my end. I have exported the report 1000 time using “Parellel” class and still issue not replicate at my end even after executing 10-12 times. Please refer the attached sample. Could you please share the sample with us so that I can replicate at my end. Also, is issue reproducible always or only once while executing many times?

    Thanks,

    Mohit

    PDFExport.zip

  • Posted 17 May 2018, 6:04 am EST

    Hello Mohit,

    Thanks a lot for the quick response, the code is quite complex and I can’t share it openly however I will try to create a sample scenario and share it with you and will check the sample you attached as well, again, thanks a lot for your help!

    The issue is only reproducible when different instances of the same application run the export process, instead of using Parallel tasks we have multiple instances of the same job that will do the exportation, each on its own AppDomain. If I run just one instance of the application it will export everything with no exceptions.

    Thanks again

  • Posted 17 May 2018, 6:34 am EST

    I just saw your sample, in our case, since the same application will be instantiated multiple times, both Run and Export methods will be running concurrently in different AppDomains, I changed the MergeReport to the code below then the exception was thrown (small numbers on k didn’t throw exception but when I changed to 50 it did):

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using GrapeCity.ActiveReports.Document;

    using System.Threading;

    using GrapeCity.ActiveReports;

    using System.Xml;

    using System.IO;

    using System.Reflection;

    using System.Threading.Tasks;

    namespace ImageExceptionApp

    {

    class MergeReport

    {

    int t;

    int k;

    object locker;

        public void Run()
        {
            t = 0;
            k = 50;
            locker = new Object();
            Parallel.For(0, k, i=>CreateDocument());
            
        }
    
        static int I = 0;
        public  void CreateDocument()
        {
            try
            {
                SectionReport report = new SectionReport();
                XmlReader xmlR = null;
                string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\..\..\..\Resources\template.rpx";
                xmlR = new System.Xml.XmlTextReader(path);
                report.LoadLayout(xmlR);
                xmlR.Close();
                report.Run();
                GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdf = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
                pdf.Export(report.Document, "test" + I++.ToString() + ".pdf");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
    

    }

    Thanks again

  • Posted 17 May 2018, 3:45 pm EST

    Hello Leandro,

    This error occurs only in the trial version. However, you can avoid this error by adding “Licenses.licx” file having both “SectionReport” and “PDF Export” entry as follow:

    
    GrapeCity.ActiveReports.SectionReport, GrapeCity.ActiveReports.v12
    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport, GrapeCity.ActiveReports.Export.Pdf.v12
    
    

    Also, please refer the attached sample license file.

    Thanks,

    Mohit

    Licenses.zip

  • Posted 18 May 2018, 7:05 am EST

    That did the job Mohit, thanks a lot!

    I didn’t reply to the other thread yet because I didn’t have time to create a separated scenario to reproduce the case but will do as soon as possible, again, thanks a lot for the quick response!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels