加载报表失败问题

caishiwen 2008-12-08 11:24:19
我用C#开发一个程序,用到了vs2005内部集成的水晶报表,当我打包成安装程序时,水晶报表打印块出现错了.请问我该如何部署,才能让水晶报表运行正常呢?
谢谢!


错误如下:
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.Exception: 加载报表失败。 ---> System.Runtime.InteropServices.COMException (0x80004005): 系统找不到指定的路径。 在 CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
--- 内部异常堆栈跟踪的结尾 ---
在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
在 KuCunGuanLi.CangKu.frmYearReport.CrystalReports(String crystalreportname) 位置 G:\work\进销存\仓库管理1208\仓库管理\KuCunGuanLi\CangKu\frmYearReport.cs:行号 143
在 KuCunGuanLi.CangKu.frmYearReport.frmYearReport_Load(Object sender, EventArgs e) 位置 G:\work\进销存\仓库管理1208\仓库管理\KuCunGuanLi\CangKu\frmYearReport.cs:行号 80
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** 已加载的程序集 **************
mscorlib
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
KuCunGuanLi
程序集版本: 1.3.1.0
Win32 版本: 1.3.1.0
基本代码: file:///G:/work/进销存/仓库管理1208/仓库管理/KuCunGuanLi/bin/Debug/KuCunGuanLi.exe
----------------------------------------
System
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
mscorlib.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.42 (RTM.050727-4200)
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
CrystalDecisions.Windows.Forms
程序集版本: 10.2.3600.0
Win32 版本: 10.2.51014.0
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Windows.Forms/10.2.3600.0__692fbea5521e1304/CrystalDecisions.Windows.Forms.dll
----------------------------------------
CrystalDecisions.Shared
程序集版本: 10.2.3600.0
Win32 版本: 10.2.51014.0
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Shared/10.2.3600.0__692fbea5521e1304/CrystalDecisions.Shared.dll
----------------------------------------
CrystalDecisions.CrystalReports.Engine.resources
程序集版本: 10.2.3600.0
Win32 版本: 10.2.51014.0
基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.CrystalReports.Engine.resources/10.2.3600.0_zh-CHS_692fbea5521e1304/CrystalDecisions.CrystalReports.Engine.resources.dll
----------------------------------------

************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。

例如:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

启用 JIT 调试后,任何无法处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。

----------------------------------
说明:报表的路经是没有问题的。

...全文
644 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxlongnw 2009-05-13
  • 打赏
  • 举报
回复
以下是最近做的一个项目中使用水晶报表后的总结,可供参考:(用的也是vs2005内部集成的水晶报表)
整个使用和发布水晶报表的过程:
1.新建一个Dataset,在Dataset中建你所要的表Table
2.将建好的Dataset做为数据源模板,构建想要的水晶报表样式,该报表文件可暂命名为:CrySJBB.rpt
2.写“Select”的SQL语句,注意:Table中的字段一定要在所写的语句中的字段找得到!
3.为报表赋数据源并加载该报表,代码可如下:
//reportPath为报表路径,下面会谈起怎么取的。
reportDocument1.Load(reportPath);
reportDocument1.SetDataSource(数据源);
CryReViewer.ReportSource = reportDocument1;

4.注:加载该报表时的路径一定不能用网上所说的取应用程序下的相对路径,因为那样在发布后是找不到报表路径的.
5.报表文件CrySJBB的路径rptreportPath的取法:
(1).将建好的报表文件CrySJBB放在某工程下(也可以放在应用程序下,这里以应用程序为例)的Resources资源文件中,这一点应该会添加吧。(点开Properties下的Resources.resx,双击它,点击里头的“添加资源”的“添加现有文件”即可)
(2).写代码,去取得该Resources资源文件下的报表文件,这样做,不但是运行程序还是发布程序,都能自动去找到报表文件。(我这是C/S模式,B/S模式也可以这样做,只是将取得报表文件后的路径重新设置一下就可以了)
using System.Resources;//引用命名空间;

string AppPath = Application.StartupPath; //C/S模式下下载客户端到本地的应用程序路径;
string RptFileFullName = AppPath + @"\CrySJBB.rpt"; //假定取得报表文件后的路径;
//取得Resources资源文件下的报表文件,ZJFF应用程序名
ResourceManager resources = new ResourceManager(typeof(ZJFF.Properties.Resources));
byte[] bytes = (byte[])resources.GetObject("CrySJBB");//只写报表名称,不带后缀

if (File.Exists(RptFileFullName)) //若假定路径中有该文件,则删除,否则新建一个
File.Delete(RptFileFullName);
FileStream fileStream = new FileStream(RptFileFullName, FileMode.CreateNew);
BinaryWriter binWriter = new BinaryWriter(fileStream);
binWriter.Write(bytes, 0, bytes.Length);
binWriter.Close();
fileStream.Close();
reportPath = RptFileFullName;

reportPath 就是最后我们要取得路径,即服务器上已下载到本地后的报表路径,加载这个路径就可以查看我们已经做好的水晶报表了。
6.在发布时,不需要网上所说的合并模块之类,哪些根本没啥用处,因为在C/S模式下,以后程序升级时,用合并模块的话是不会自动查找是否有新版本的程序并且自动升级的。
发布步骤:
(1).点击应用程序的【属性】
(2).点击【发布】项中的【系统必备】,选择其中的.NET Framework 2.0 和Crystal Report for .NET Framework 2.0两项就可以了,
(3).然后点击发布向导,一步一步进行直至完成,或者填写其他项直接点击立即发布,这样发布就完成了!
wsg9913028 2008-12-08
  • 打赏
  • 举报
回复
从这句来看,可能是报表文件没有找到
System.Exception: 加载报表失败。 ---> System.Runtime.InteropServices.COMException (0x80004005): 系统找不到指定的路径。

你用以下的方法试一下:

CommonReport = new ReportDocument();
//取出报表
string reportPath = Server.MapPath(@"ReportName.rpt");

//根据路径装载指定报表文件,以进行报表配置操作
CommonReport.Load(reportPath);
CommonReport.SetDataSource(ds);
CrystalReportViewer1.ReportSource = CommonReport;
阿泰 2008-12-08
  • 打赏
  • 举报
回复
另外可看下
http://topic.csdn.net/u/20081205/16/9E54BA3E-9793-4191-8032-83D35C336EFD.html

看看有没有权限上的因素
阿泰 2008-12-08
  • 打赏
  • 举报
回复
你这个是winform程序吧

如果
P_Doc.Load(reportPath); //加载报表

reportPath 这个路径在客户机上是对的

那么看下客户机上的temp目录是不是满了
caishiwen 2008-12-08
  • 打赏
  • 举报
回复

DataSet ds = ClsSqlHelper.ExecuteDataSet(ClsCommLib.sfxStrCnnLink(), CommandType.StoredProcedure, "CK_CatchChuRureport", objParams);

ReportDocument reportDocument = CrystalReports("MonthReport.rpt");

reportDocument.SetDataSource(ds.Tables[0]);
this.crystalReportViewer1.ReportSource = reportDocument;

public ReportDocument CrystalReports(string crystalreportname )
{
ReportDocument P_Doc = new ReportDocument();
string reportPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,
Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
reportPath += @"\CangKu\" + crystalreportname; //获取报表路径
P_Doc.Load(reportPath); //加载报表
return P_Doc;
}

我是这样写的,我的电脑上是没问题的!

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧