Invalid file name in report

时间:2016-08-31 12:07:08

标签: c# crystal-reports

My web application is hosted with Arvixe. I also uploaded the aspnet_client folder. This worked fine but after few days it showed an error:

invalid file name

The error occurs when calling rd.Load(path). This works on my local machine and on iis7. I've tried to give full permission on c:\windows\Temp folder; used rd.Close();, rd.Dispose();, and GC.Collect(); in the code behind. I even checked increase Print Limit for Crystal Reports in the windows registry.

How can I fix this error?

CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> 
System.Runtime.InteropServices.COMException: Invalid file name. at 
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) at
 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) at 
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() --- End of inner exception stack trace --- at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() at
 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) at
 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) at STAREX.ReportViewer.Page_Load(Object sender, EventArgs e) in D:\abc\ReportViewer.aspx.cs:line 49

The page load for ReportViewer.aspx:

protected void Page_Load(object sender, EventArgs e)
{
  try
  {
    DataTable dt = new DataTable();
    if ((DataTable)Session["datatable"] != null)
    {
      dt = (DataTable)Session["datatable"];
    }
    else
    {
      dt=null;
    }
    string path = Session["path"].ToString();

    if (!File.Exists(path))
    {
      Response.Write("Unable to Locate");
    }
    else
    {
      rd = new ReportDocument();
      rd.Load(path);
      rd.SetDataSource(dt);
      CrystalReportViewer1.ReportSource = rd;
    }
  }
  catch (Exception ex)
  {
  }
}

The report is called from the Data_Entry.aspx page:

protected void lnkPrintInvoice_Click(object sender, EventArgs e)
{
  try
  {
    LinkButton lnkbtn = sender as LinkButton;
    GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
    string code = (gridDataEntryDetail.DataKeys[gvrow.RowIndex].Value).ToString();
    DataTable dt = new DataTable();
    dt = bll.td_Bll("Select * from [View_Invoice] where Invoice_No ='" + code + "' ");

    if (dt.Rows.Count > 0)
    {
      Session["Invoice"] = "Invoice";
      dt.TableName = "View_Invoice";
      Session["datatable"] = dt;
      Session["path"] = Server.MapPath("~/Report/Crybilldom.rpt");
      Response.Redirect("~/ReportViewer.aspx");
    }
  }

  catch (Exception ex)
  {
    ExceptioError.Attributes.Remove("style");
    lblExcption.Visible = true;
    lblExcption.Text = "Exception Error !\t\t" + ex.Message;
  }
}

2 个答案:

答案 0 :(得分:0)

我得到了解决方案,只需更改支持水晶的托管服务器即可。 AVEN.arvixe.com支持水晶,但有时它不支持不知道为什么,所以如果你不得不使用水晶报告,我不建议使用arvixe。

感谢。

答案 1 :(得分:0)

对我来说,答案是联系Arvixe的支持。似乎这是一个权限问题。他们的回应是:

  

我们一直在共享服务器场上进行一些系统架构更改,以便我们可以为客户提供更好的服务,我们正在努力使整个平台的配置统一。此更改期间受影响的一件事是对某些驱动器的权限。我们正在积极开发一种解决方案,为我们提供所需的安全性,同时允许Crystal报表用户访问以运行报表。

     

我已经对系统进行了一些编辑,如果您可以对其进行测试,请告诉我们是否可以解决您的问题。