当前位置:编程学习 > C#/ASP.NET >>

求高手:水晶报表发布后提示“无效文件名,加载报表失败”

各位大哥

我在做水晶报表的时候,本地可以正确浏览水晶报表,但是发布网站后,在IIS浏览,总数提示水晶报表加载错误,详细信息如下:


无效文件名。 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.InteropServices.COMException: 无效文件名。

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[COMException (0x800001fb): 无效文件名。]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +95
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +270

[CrystalReportsException: 加载报表失败。]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +333
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +876
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +84
   Report_PrintOrder.BindOrder() +276
   Report_PrintOrder.Page_Load(Object sender, EventArgs e) +36
   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) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

 
我的代码时这样的:
       TableLogOnInfo logonInfo = new TableLogOnInfo();

        FileName = Server.MapPath("~/Report/CrystalReport.rpt");
        MyReport.Load(FileName);
      

        foreach (CrystalDecisions.CrystalReports.Engine.Table tb in MyReport.Database.Tables)
        {
            logonInfo = tb.LogOnInfo;
            logonInfo.ConnectionInfo.ServerName = @".";
            logonInfo.ConnectionInfo.DatabaseName = "dbname";
            logonInfo.ConnectionInfo.UserID = "sa";
            logonInfo.ConnectionInfo.Password = "123";
            tb.ApplyLogOnInfo(logonInfo);
        }

        //这里是取的泛型集合(有数据的)
        ReportAccounts ReportAccounts = new global::ReportAccounts();
        List<MIST.Model.Accounts> list = new List<Accounts>();
        list = ReportAccounts.GetlistByCompanyId(EnterpriseId);


        CrystalReportSource1.ReportDocument.Load(FileName);
        CrystalReportSource1.ReportDocument.SetDataSource(list);  
        CrystalReportSource1.DataBind();
        CrystalReportViewer1.ReportSource = CrystalReportSource1;
        CrystalReportViewer1.DataBind();

现在我尝试了如下修改,都不行:
1、把C:\windows\temp 设为everyone可写
2、把FileName = Server.MapPath("~/Report/CrystalReport.rpt") 直接改成服务器水晶报表物理路径
3、服务器已安装水晶报表的文件CRforVS_13_0_2.exe

--------------------编程问答-------------------- 另外,我在浏览器里直接输入水晶报表的路径,如:
http://www.myweb.com/Beta/report/CrystalReport.rpt
提示:

无法找到该页
您正在搜索的页面可能已经删除、更名或暂时不可用。 
--------------------------------------------------------------------------------

请尝试以下操作:

确保浏览器的地址栏中显示的网站地址的拼写和格式正确无误。 
如果通过单击链接而到达了该网页,请与网站管理员联系,通知他们该链接的格式不正确。 
单击后退按钮尝试另一个链接。 
HTTP 错误 404 - 文件或目录未找到。
Internet 信息服务 (IIS)


实在不知道问题出在什么地方了,还请大家帮帮忙啊 --------------------编程问答-------------------- http://www.cnblogs.com/aaron_zhang/archive/2009/07/31/1535912.html --------------------编程问答-------------------- 大神,请问你这个问题解决了吗?是怎么解决的?我也遇到了相同的问题。求指教。。。。 --------------------编程问答-------------------- 相对路径的问题,再有一个就是你的 匹配的DLL 全不全 --------------------编程问答-------------------- 都 404 了 证明他不存在, 看这个文件是否被 复制到 虚拟目录下 ,如果没有 那你可以吧做编译方式作为内容进行 较新复制。然后从新生成,文件会跑到他该去目录了 --------------------编程问答-------------------- 这是我的错误,文件路径应该是对的,我在vs上运行就没错,但是发布到iis就报这个错!!!!!
无效文件名。 
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.Runtime.InteropServices.COMException: 无效文件名。

源错误: 


行 43:             string s = Server.MapPath("StatisticsRetentionReasonReport.rpt");
行 44:             CrystalReportSource1.Report.FileName = "StatisticsRetentionReasonReport.rpt";
行 45:             CrystalReportSource1.ReportDocument.Load(Server.MapPath("StatisticsRetentionReasonReport.rpt")); 
行 46:             //注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
行 47:             DataTable dt = ds.Tables["sql"];
 

源文件: F:\HospitalScienceService\CLSOFT.Web\EmergencyReport\StatisticsRetentionReason.aspx.cs    行: 45 

堆栈跟踪: 


[COMException (0x800001fb): 无效文件名。]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +95
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +270

[CrystalReportsException: 加载报表失败。]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +332
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.get_ProductLocaleID() +31
   CrystalDecisions.ReportSource.CachedObjectReportSource.GetReport(RequestContext context, Boolean bAddToCacheWhenCreated) +451
   CrystalDecisions.Web.CrystalReportSource.get_ReportDocument() +201
   CLSOFT.Web.EmergencyReport.StatisticsRetentionReason.Button_push_Click(Object sender, String whereStr) in F:\HospitalScienceService\CLSOFT.Web\EmergencyReport\StatisticsRetentionReason.aspx.cs:45
   CLSOFT.Web.EmergencyReport.StatisticsRetentionReason.Page_Load(Object sender, EventArgs e) in F:\HospitalScienceService\CLSOFT.Web\EmergencyReport\StatisticsRetentionReason.aspx.cs:27
   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) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

 

--------------------编程问答-------------------- 解决了没?  求指教 --------------------编程问答-------------------- 晕,问题解决了吗?我也遇到了..VS调试的时候,可以完好显示报表,但是部署到IIS上的时候就出现 无效文件名的错误,无效文件名?难道是IIS的错误??
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,