Pages

Friday, November 25, 2011

Crystal Reports: Fix for "Load report failed" error.

The problem: You want to display a Crystal Reports file programmatically on your website. When you try to open the report -- say, by calling the Load(Path) method of a ReportDocument object -- your code throws an exception with the message Load report failed. The inner exception reports Invalid file name, but you have verified that the path points right at a valid .rpt file. Perhaps the report mechanism worked just fine until you made some seemingly unrelated changes that affected system permissions.

The fix: When Crystal Reports opens a file, it uses the Windows temporary folder (typically C:\Windows\Temp\) as a scratch-pad. You need to give Crystal Reports explicit permission to read and write to this folder.

How-to: Under XP, ASP.NET runs CR under ASPNET; with most of the Windows Server flavors, CR runs as NETWORK SERVICE. Make sure that this identity has permission to read and write to the Windows temporary folder.

Further: This issue seems to be limited just to ASP. In my office, we have CR embedded in several Windows Forms applications and have never had any problems. At a guess, CP runs with the permissions of the app's user, who automatically has the right access. We ran into this problem when our report server was demoted from being a domain controller, which reset things. I can't guarantee that this tip will work, but it may help prevent a very frustrating few days with your boss demanding hourly when the report server will be back on line.

In some cases in a Windows From Application (.NET environment) when a report is loaded, a copy of it is created in Windows Temp folder and after a while the Temp folder does not allow the new copies of report to be created.
In this situation, emptying Temp folder is helpful and will solve the problem.

No comments:

Post a Comment