Crystal Report“文件名无效”。问题

时间:2012-04-23 15:56:48

标签: c# visual-studio-2008 crystal-reports-2008

我上传了我的WebApplication。我的应用程序是在带有Crystal Reports 2008 sp3的VS2008中。 我上传了并行plex服务器。我在Bin文件夹中添加了所有必需的Crystal报表。我的报告路径也是正确的。

我收到的错误是

Line 41:         ReportDocument myreport = new ReportDocument();
Line 42:         string reportPath = Server.MapPath("~/CrystalReport.rpt");
Line 43:         myreport.Load(reportPath);
Line 44: 
Line 45:         myreport.SetDataSource(ds);


[COMException (0x800001fb): Invalid file name.]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +95
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +356

[CrystalReportsException: Load report failed.]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +418
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +895
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +84
   _Default.CreateReport() in d:\inetpub\vhosts\mydomain.in\subdomains\mysubdomain\httpdocs\Default.aspx.cs:43
   _Default.Page_Load(Object sender, EventArgs e) in d:\inetpub\vhosts\mydomain.in\subdomains\mysubdomain\httpdocs\Default.aspx.cs:21
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

我无法获取错误的位置..报告位于根文件夹本身。那么这个问题是什么呢?还有一个文件夹aspnet_client。那是我们需要做的吗?

请等待回复

3 个答案:

答案 0 :(得分:15)

同样的问题让我感到很长一段时间。现在我找到了答案:)

转到c:\windows\temp文件夹及其properties->security 添加新用户“IIS_IUSRS”并赋予其完整/读写能力。

它解决了我的问题。

希望它也适合你:)

答案 1 :(得分:4)

这是需要检查的内容。

您收到此错误是因为文件名,路径无效或CR无法访问该文件。

如果路径和文件名正常,则需要确保网络服务 Temp 文件夹具有读/写权限(一般C:\windows\Temp)。

如果它仍然无法解决问题,那么可能你的Temp文件夹已满,而且CR没有清理垃圾。

如果是这种情况,那么您需要确保正确处置您的报告对象并调用 GC 进行清理。

有时CR表现不可预测。我已经以一种艰难的方式了解到这一点,即使您在ReportDocument对象上调用dispose后跟GC.Collect(),仍然无法清除 Temp 文件夹中的.rpt个文件起来。没有限制。在Temp文件夹中的.rpt文件,之后CR停止执行进一步的报告请求。

奇怪的是,当您在函数或事件处理程序中声明ReportDocument对象时会发生这种情况。但是如果你在一个页面范围的全局范围中声明你的ReportDocument,那么当你调用Dispose方法时,crystal报告会很快清除temp .rpt文件!!

我希望这能帮助您解决问题。

答案 2 :(得分:0)

还要检查的是,服务器上已添加了所有相应的IIS角色服务。我们在新安装的生产服务器上提到了同样的问题,但在我们的本地开发环境中却没有。事实证明,IIS被添加为服务器角色,但ASP.NET&服务器端包含未添加为角色服务&因此,Crystal Report Viewer无法呈现任何报告。

如果您运行的是Windows Server 2008,则可以管理这些角色&角色服务通过服务器管理器工具。