Hi,
I am using crystal reports with Visual Studio 2005. And that was working fine in development environment.
After I deployed it to server, It is giving me this error.
#######################################################
System.Exception: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80000220): Error in File C:\WINDOWS\TEMP\rptInvoice {D21318F6-F9E2-4FDA-8CA9-95B11CB95993}.rpt:
Access to report file denied. Another program may be using it.
at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
#######################################################
Here is my code that I am using to export crystal report to a .pdf file and I am saving this temporary file to one of my folder in my website directory which has full permissions for "NetWork Service" account.
#######################################################ExportOptions exportOptions = new ExportOptions();DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();PdfRtfWordFormatOptions formatTypeOptions = new PdfRtfWordFormatOptions();pdfFileName = "Inv" + "_" + System.DateTime.Now.Year + "_" + System.DateTime.Now.Month + "_" +System.DateTime.Now.Day + "_" +System.DateTime.Now.Hour + "_" + System.DateTime.Now.Minute + "_" + System.DateTime.Now.Second + "_" + System.DateTime.Now.Millisecond + ".pdf"; try{if (System.IO.Directory.Exists(appPath + "\\tempReports\\") == false){System.IO.Directory.CreateDirectory(appPath + "\\tempReports\\");}if (System.IO.File.Exists(appPath + "\\tempReports\\" + pdfFileName) == true){System.IO.File.Delete(appPath + "\\tempReports\\" + pdfFileName);}}catch (Exception ex2){Response.Write(ex2.Message);return;}diskFileDestinationOptions.DiskFileName = appPath + "\\tempReports\\" + pdfFileName;exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;exportOptions.DestinationOptions = diskFileDestinationOptions;exportOptions.FormatOptions = formatTypeOptions;theReport.Export(exportOptions);applicationURL = HttpContext.Current.Request.Url.GetLeftPart(System.UriPartial.Authority) +"/" + HttpContext.Current.Request.ApplicationPath + "/";displayPDF_URL = applicationURL + "/" + "tempReports//" + pdfFileName;Response.Redirect(displayPDF_URL, false);
#######################################################
Now it seems like Crystal Reports is trying to extract some temp files using "C:\Windows\Temp" directory.
So Should I give "Network Service" permissions to "C:\Windows\Temp" directory also
OR
Can I change this crystal report's temporary extraction file path to any of my path instead of "C:\Windows\Temp"?
OR
Does crystal report use windows temp directory to create some temp files during the process?
Thanks
![]() |
0 |
![]() |
No problem, this is security problem we can solve this
in your web.config file there is a tag <identity> within this tag set impersonate=false if its yes then we should pass the userid and password of the windows login
If this post is answer of your question then don't forgot to Click Mark As Answer
![]() |
0 |
![]() |
Thanks for your reply.
Actually I tried giving full permissions to "C:\Windows\Temp" folder for "NetWork Service", and it worked.
Thanks again
![]() |
0 |
![]() |
jeyaseelan@ajsquare.net:
No problem, this is security problem we can solve this
in your web.config file there is a tag <identity> within this tag set impersonate=false if its yes then we should pass the userid and password of the windows login
It worked great for me!!
Thanks a lot, you saved me hours of research
![]() |
0 |
![]() |
Niravparekh thanks for your feedback.
By your idea if you handover the project to client then the client wont allow to give the permission to Temp folder.
If this post is answer of your question then don't forgot to Click Mark As Answer
![]() |
0 |
![]() |