CrystalDecisions.CrystalReports.Engine.LoadSaveReportException:加载报告失败 - VB.NET 2003
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15828111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Load report failed - VB.NET 2003
提问by Mark
Anybody know why the below error exist?
有人知道为什么会出现以下错误吗?
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Load report failed
回答by reckface
From your comments about windows\Temp, that is caused by the application pool's identity not having access to c:\windows\Temp (and possibly to the reports folder).
根据您对 windows\Temp 的评论,这是由于应用程序池的身份无法访问 c:\windows\Temp(以及可能无法访问报告文件夹)造成的。
You can solve this problem by giving the application pool credentials that do have the necessary permissions, or giving read write permissions to "Network User" to the c:\windows\temp folder (and again, possibly to the reports folder).
您可以通过向 c:\windows\temp 文件夹(也可能是报告文件夹)授予具有必要权限的应用程序池凭据,或向“网络用户”授予读写权限来解决此问题。
The reason why this folder is required is that the crystal runtime creates a dynamic copy of the report at runtime and places it in the %temp% folder. It is the temp folder copy (with a GUID appended to the original file name) that is shown in the web browser. This is by design and is a useful feature to ensure the live report is safe.
之所以需要这个文件夹,是因为 Crystal 运行时会在运行时创建报表的动态副本,并将其放置在 %temp% 文件夹中。它是 Web 浏览器中显示的临时文件夹副本(在原始文件名后附加了 GUID)。这是设计使然,是确保实时报告安全的有用功能。
Following from this, you will have to do a proper cleanup after loading every report because they just stay there and fill up the temp folder!
在此之后,您将必须在加载每个报告后进行适当的清理,因为它们只是停留在那里并填满临时文件夹!
Something like:
就像是:
CrystalReportViewer1.Dispose(); // if using the viewer
CrystalReportViewer1 = null;
report.Close(); // I can't remember if this is part of the reportDocument class
report.Dispose();
report = null;
GC.Collect(); // crazy but true. Monitor the temp folder to see the effect
回答by Steven
Reckface's answer was clear enough, but to add something up.
Reckface 的回答很清楚,但要补充一点。
I managed to get it working using this:
我设法使用这个让它工作:
protected void Page_Unload(object sender, EventArgs e)
{
if (reportDocument != null)
{
reportDocument.Close();
reportDocument.Dispose();
crystalReportViewer1.Dispose();
}
}
Doing so may cause issues with the buttons on the toolbar, they can't find the document path anymore because the document is disposed. In that case the document needs to load the path again during postbacks: source
这样做可能会导致工具栏上的按钮出现问题,因为文档已被处理,它们无法再找到文档路径。在这种情况下,文档需要在回发期间再次加载路径:源
回答by nunzabar
Did you even bother to Google it? This is a common exception; there are hundreds of posts about it scattered around the intertubes.
你有没有费心去谷歌一下?这是一个常见的例外;有数百个关于它的帖子散布在中间管周围。
The Crystal .NET runtime has famously cryptic error messages. This one just means that the .rpt file (or embedded report) could not be loaded. There are several possible root causes: wrong filename or path, security violation, you are not disposing of old reports properly and windows/temp is getting hogged up, etc.
Crystal .NET 运行时具有众所周知的神秘错误消息。这只是意味着无法加载 .rpt 文件(或嵌入式报告)。有几个可能的根本原因:错误的文件名或路径、安全违规、您没有正确处理旧报告以及 windows/temp 被占用等。
Do some research. If you're still stuck, come back and elaborate on the problem (do any of your reports work, is this a web app?, what code are you using, etc.)
做一些研究。如果您仍然卡住,请返回并详细说明问题(您的任何报告是否有效,这是网络应用程序吗?您使用的是什么代码等)

