如何部署Crystal Report

来源:互联网 发布:高性能mysql第4版百度 编辑:程序博客网 时间:2024/03/29 09:57

照一般建立安裝專案,加入合併模組:

(1)regwiz.msm
(2)Managed_cht.msm
(3)managed.msm
(4)Database_Access.msm
(5)Database_Access_cht.msm
(6)dotnetfxredist_x86_cht.msm
其中(3)(6)項在建立完專案時自動加入到偵測到的相依性其餘需手動加入,在第(1)項的屬性中需設定license key(在屬性視窗中可找到)

license key( xxxxx-xxxxxxx-xxxxxxx)說明中最後一個選項(關於 microsoft....)可以找到。
若是報表連結時使用到DataSet ,則須另外加入 VC_CRT.msm VC_STL.msm 兩個項目。且需先在檔案系統中增加系統資料夾 再將VC_CRT.msm VC_STL.msm 兩個項目的Module Retargetable Folder的屬性設為系統資料夾,接下來便開始建置...........

-----------------------------------------------------------------------------------------------
Crystal Report
-------------------------------------------------------------------------------------------------------

水晶报表打包的一些注意事项
【摘 要】.net打包真的很麻烦,特别是碰到要用水晶报表,那打包就更加复杂了。
--------------------------------------------------------

 

.net打包真的很麻烦,特别是碰到要用水晶报表,那打包就更加复杂了。

如果你想在“干净”的机器上成功安装和使用水晶报表,请按照下列步骤:

1)新建“安装和部署项目”-->“安装向导”
(2)选择项目类型(这里选“创建用于windows应用程序的安装程序”)-->下一步
(3)选择要包含的文件:要部署使用 Crystal Reports for Visual Studio .NET 2003 的程序,需要添加合并模块(在解决方案资源管理器中tree的顶端节点右键-->添加).
Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_Managed2003.msm
Crystal_regwiz2003.msm
VC_User_CRT71_RTL_X86_---.msm
VC_User_STL71_RTL_X86_---.msm
你可以 'C:/Program Files/Common Files/Merge Modules' 文件夹下找到替换的合并模块。
(4) 打开解决方案-->右键点击Crystal_regwiz2003.msm 的属性,在“MergeMouduleProperties”里的“License Key”填入:***************************(这个是你生成Crystal Report是用到的注册号的密码!)
(5)生成解决方案

如果没有第四步,会产生在执行打印报表时提示keycodev2.dll或者无效密码的错误。

以上的步骤,如果你的“干净”的机器上装有水晶报表,那么到这里完全就可以了。

如果你不希望在“干净”的机器上装水晶报表,继续以下的步骤:

1. 在“添加项目输出组”中,选择“主输出”,然后单击“确定”。

将自动添加所有依赖项,如 dotnetfxredist_x86_enu.msm和dotnetcrystalreports.msm。

2.需要将dotnetcrystalreports.msm排除在项目之外,在解决方案资源管理器中右击这个模块的右键,选择“排除”。

3.在解决方案资源管理器中,右击安装项目,指向“添加”,然后单击“合并模块”。

4.在“添加模块”对话框中,选择下列要添加到安装项目的合并模块,然后单击“打开”:

* reportengine.msm,

* crnetruntime.msm

* license.msm

* mapping.msm (可选,当在报表中使用了geographic maps时)

5.在解决方案资源管理器中,右击 license.msm 文件,然后选择“属性”。

6.在“属性”窗口中,展开 MergeModuleProperties,然后在“许可证密钥”属性框中输入一个有效的许可证密钥。

注意 : 每当部署 Crystal Reports 应用程序时,必须提供许可证密钥。

7.从“生成”菜单中,选择“生成解决方案”以生成应用程序

如果以上步骤没有的化,会提示“load crpe32.dll failed”的错误。

用到的模块下载地址: http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netmergemodules_chs.zip.asp

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netredist_chs.zip.asp

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9rdcmergemodules_chs.zip.asp

如果你的机器上装的是windows 98,不继续以下的步骤会产生"Load Report Failed" (CRQE.dll)的错误。
报表在部分Win98的客户端可以载入,在部分Win98的客户端载入报表时却提示"Load Report Failed"是因为水晶报表运行时所需的 CRQE.dll 在客户端的系统注册不正确,而原因又是ATL.dll 的版本不对(Windows 98/ME下的正确版本号应为3.0.8449)。
解决办法有两条:
1.在客户端安装 IE6.0,难怪有的客户端运行正常。
2.将 ATL.msm 模块添加到安装工程,ATL.msm 是 Visual Studio installer 1.1 的一部分,可以去微软的网站http://msdn.microsoft.com/vstudio/downloads/tools/vsi11/download.aspx下载, 添加办法同上。

至此,可以说打包基本完成。不过还要注意:

如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。

如果你用的是水晶报表的拉模式,你就一定要写上登陆信息:

crReportDocument = new OracleReport();

//Set the crConnectionInfo with the current values stored in the report
crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;

/* Populate the ConnectionInfo Objects Properties with the appropriate values for
the ServerName, User ID, Password and DatabaseName. However, since Oracle
works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
Therefore, the DatabaseName property must be set to a BLANK string. */
crConnectionInfo.DatabaseName = "";
crConnectionInfo.ServerName = "Your Server Name";
crConnectionInfo.UserID = "Your User ID";
crConnectionInfo.Password = "Your Password";

//Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database;

//Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables;

//Loop through each Table object in the Tables collection and apply the logon info
//specified ealier. Note this sample only has one table so the loop will only execute once
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo (crTableLogOnInfo);

// if you wish to change the schema name as well, you will need to set Location property as follows:
// crTable.Location = "<new schema name>." + crTable.Name;
}

//Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
crystalReportViewer1.ReportSource = crReportDocument;

还有一点要注意:
如果你用到了子报表,一定要处理:

//Go through each sections in the main report and identify the subreport by name
crSections = crReportDocument.ReportDefinition.Sections;

foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
//loop through all the report objects to find all the subreports
foreach(ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
//you will need to typecast the reportobject to a subreport
//object once you find it
crSubreportObject = (SubreportObject)crReportObject;

//open the subreport object
crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
//Once the correct subreport has been located pass it the
//appropriate dataset
if(crSubReportDoc.Name == "FirstSub")
{
//crSubReportDoc.Database.Tables[0].SetDataSource(ds);
crSubReportDoc.SetDataSource(ds);
}
}
}
}
crystalReportViewer1.ReportSource = crReportDocument;

同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);

6.在“属性”窗口中,展开 MergeModuleProperties,然后在“许可证密钥”属性框中输入一个有效的许可证密钥。

注意 : 每当部署 Crystal Reports 应用程序时,必须提供许可证密钥。

7.从“生成”菜单中,选择“生成解决方案”以生成应用程序

如果以上步骤没有的化,会提示“load crpe32.dll failed”的错误。

用到的模块下载地址: http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netmergemodules_chs.zip.asp

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netredist_chs.zip.asp

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9rdcmergemodules_chs.zip.asp

如果你的机器上装的是windows 98,不继续以下的步骤会产生"Load Report Failed" (CRQE.dll)的错误。
报表在部分Win98的客户端可以载入,在部分Win98的客户端载入报表时却提示"Load Report Failed"是因为水晶报表运行时所需的 CRQE.dll 在客户端的系统注册不正确,而原因又是ATL.dll 的版本不对(Windows 98/ME下的正确版本号应为3.0.8449)。
解决办法有两条:
1.在客户端安装 IE6.0,难怪有的客户端运行正常。
2.将 ATL.msm 模块添加到安装工程,ATL.msm 是 Visual Studio installer 1.1 的一部分,可以去微软的网站http://msdn.microsoft.com/vstudio/downloads/tools/vsi11/download.aspx下载, 添加办法同上。

至此,可以说打包基本完成。不过还要注意:

如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。

如果你用的是水晶报表的拉模式,你就一定要写上登陆信息:

crReportDocument = new OracleReport();

//Set the crConnectionInfo with the current values stored in the report
crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;

/* Populate the ConnectionInfo Objects Properties with the appropriate values for
the ServerName, User ID, Password and DatabaseName. However, since Oracle
works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
Therefore, the DatabaseName property must be set to a BLANK string. */
crConnectionInfo.DatabaseName = "";
crConnectionInfo.ServerName = "Your Server Name";
crConnectionInfo.UserID = "Your User ID";
crConnectionInfo.Password = "Your Password";

//Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database;

//Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables;

//Loop through each Table object in the Tables collection and apply the logon info
//specified ealier. Note this sample only has one table so the loop will only execute once
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo (crTableLogOnInfo);

// if you wish to change the schema name as well, you will need to set Location property as follows:
// crTable.Location = "<new schema name>." + crTable.Name;
}

//Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
crystalReportViewer1.ReportSource = crReportDocument;

还有一点要注意:
如果你用到了子报表,一定要处理:

//Go through each sections in the main report and identify the subreport by name
crSections = crReportDocument.ReportDefinition.Sections;

foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
//loop through all the report objects to find all the subreports
foreach(ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
//you will need to typecast the reportobject to a subreport
//object once you find it
crSubreportObject = (SubreportObject)crReportObject;

//open the subreport object
crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
//Once the correct subreport has been located pass it the
//appropriate dataset
if(crSubReportDoc.Name == "FirstSub")
{
//crSubReportDoc.Database.Tables[0].SetDataSource(ds);
crSubReportDoc.SetDataSource(ds);
}
}
}
}
crystalReportViewer1.ReportSource = crReportDocument;

同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);

6.在“属性”窗口中,展开 MergeModuleProperties,然后在“许可证密钥”属性框中输入一个有效的许可证密钥。

注意 : 每当部署 Crystal Reports 应用程序时,必须提供许可证密钥。

7.从“生成”菜单中,选择“生成解决方案”以生成应用程序

------------------------------------------------------------------------

初识Windows功能增强“插件”MSI

我们经常可以看到许多软件只有一个扩展名为MSI的文件,双击这个文件运行,就会出现和Windows应用软件安装非常相似的安装过程,MSI文件到底是什么?为什么许多软件开始用MSI格式来发行呢?请听我慢慢说来。

1.MSI文件的由来
说到MSI文件,不得不先说说WindowsInstaller,它不只是安装程序,而是可扩展的软件管理系统。WindowsInstaller的用途包括:管理软件的安装、管理软件组件的添加和删除、监视文件的复原以及使用回滚技术维护基本的灾难恢复。另外,WindowsInstaller还支持从多个源位置安装和运行软件,而且可以由想要安装自定义程序的开发人员自定义。要想使用这些功能,就必须通过MSI文件。MSI文件是WindowsInstaller的数据包,它实际上是一个数据库,包含安装一种产品所需要的信息和在很多安装情形下安装(和卸载)程序所需的指令和数据。MSI文件将程序的组成文件与功能关联起来。此外,它还包含有关安装过程本身的信息:如安装序列、目标文件夹路径、系统依赖项、安装选项和控制安装过程的属性。

2.MSI的优势
WindowsInstaller技术就是合并在一起发挥作用的两个部分:客户端安装程序服务(Msiexec.exe)和Microsoft软件安装(MSI)软件包文件。

Msiexec.exe程序是WindowsInstaller的一个组件。当Msiexec.exe被安装程序调用时,它将用Msi.dll读取软件包文件(.msi)、应用转换文件(.mst)并合并由安装程序提供的命令行选项。WindowsInstaller执行所有与安装有关的任务:包括将文件复制到硬盘、修改注册表、创建桌面快捷方式、必要时显示提示对话框以便用户输入安装首选项。


当双击MSI文件的时候,与之关联的WindowsInstaller的一个文件Msiexec.exe被调用,它将用Msi.dll读取软件包文件(.msi)、应用转换文件(.mst)进行进一步处理,然后WindowsInstaller执行所有与安装有关的任务:包括将文件复制到硬盘、修改注册表、创建桌面快捷方式,必要时显示提示对话框以便用户输入安装需要的信息,就这样,一个程序安装到了你的电脑上。
采用MSI安装的优势在于你可以随时彻底删除它们,更改安装选项,即使安装中途出现意想不到的错误,一样可以安全地恢复到以前的状态,正是凭着此强大功能,越来越多的软件开始使用MSI作为发行的方式了。 如果你对MSI文件感兴趣,可以用WinRAR等压缩软件打开,看一下里面的内容,满足一下好奇心。

3、MSI格式文件安装支持程序:WinMe和WinXP对MSI支持得很好,但其他版本的Windows就需要安装一个插件才能使用MSI格式的文件。

------------------------------------------------------------------