Access to report file denied - Crystal Report error

Bobaran98
Bobaran98 used Ask the Experts™
on
I have a simple web app that I'm developing in VB.NET in Visual Studio 2005.  It pulls values from a database and sends them to a Crystal Report RPT file to generate a PDF.  All of this works fine in debugging mode in VS on my webserver; when it loads the webpage via localhost, my PDF is generated no problem.

I cannot get it to work over the Internet.  I've got the web app's directory configured in IIS as a virtual directory, and I've tried this both with precompiled and un-compiled files.  Either way, I get the following error:

Error in File C:\WINDOWS\TEMP\Statements_Web_Final {54C2CC68-48EE-41E5-896B-F732A10E21EA}.rpt:
Access to report file denied. Another program may be using it.

Note #1 - I don't think this problem has anything to do with the Crystal 15-reports-at-a-time licensing issue, as has been mentioned in other expert solutions.  My web app fails to generate even a single report.

Note #2 - I tried changing the temp directory in the project's web.config file, and I made sure that folder allows full access for Everyone.  However, it's still trying to write to the C:\Windows\Temp folder (and in fact, every time I run my page, it does create an RPT file in the Windows temp folder).

Thoughts?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
Crystal Reports uses the folder in the TMP environmental variable to store its temp files. You can change the TMP environment variable to whatever location you want and it should work.

System.Environment.SetEnvironmentVariable("TMP", TempRoot)

http://www.anewdevelopment.com/2006/11/crystal-reports-access-is-denied.html
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Also does the web user have permissions to the server temp directory?

It won't be running on the local box.

mlmcc

Author

Commented:
Awesome.  Thank you!  I had the correct temp directory specified in my webconfig file, and I tried the code from the link you gave me... still didn't work (error message still indicated it was trying to access C:\Windows\Temp).  However, I tried just setting that TempRoot variable directly, and it worked like a charm.  Thank you!  I feel better about kicking back for the weekend now. :-)

Author

Commented:
Thanks for the attention, mlmcc.  Yes, the web user had permission.
Most Valuable Expert 2012
Top Expert 2014

Commented:
I am glad your problem is solved now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial