Crystal Report在WPF中不起作用 [英] Crystal Report Does not work in wpf

查看:68
本文介绍了Crystal Report在WPF中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在使用.Net Framework 4.0的VS2010中创建了一个wpf项目,并使用Crystal Report进行报告.在调试和运行中,它可以正常运行,但是当我使用安装文件安装程序时,则会出现类似程序已停止工作"的错误.我安装了cr运行时引擎. CR版本是13.0.4.如果未显示报告,则程序可以正常工作.唯一的问题是显示报告.我试图将Crystal Report引用作为dll添加到安装程序中,这不起作用.已安装运行时引擎.合并模块被添加到安装程序项目中.我找不到其他解决方案.
在此先感谢您的帮助.

Hi people, I create a wpf project in VS2010 with .Net Framework 4.0 and I use crystal report for reporting. In debug and run it perfectly works, but when I install program by using setup file, then It gives an error like "program has stopped working". I installed cr runtime engine. CR version is 13.0.4. If report were not shown, then program works correctly. Only problem is in showing report. I trying to add Crystal Report references as dll into setup, which does not work. Runtime Engine is installed. Merge Modules are added into Setup Project. I can not find another solution.
Thanks in advance for help.

推荐答案

我具有与VS2010 + net framework 4.0相同的配置,并且我使用了Crystal Report,但工作正常,部署时没有问题.
我认为问题在于,当您安装安装程序时,您的应用程序找不到报告路径.请确保安装将报告放置在您的应用程序尝试加载报告的正确位置.
I have the same configuration VS2010 + net framework 4.0 and i use crystal report but it work fine, no problem when i deploy.
i think the problem is that when you install your setup your application doesn''t find the report path. be sure the install put the report in the right place that your application try to load it.


尝试执行此操作对我来说很好
该报告必须位于执行程序集目录的一个目录中

Try this it work fine with me
the report must be in one Directory of the Executing Assembly Directory

try
{			  
string ReportPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\ReportFolder\ReportName.rpt";
					  
rptDocument.Load(ReportPath);


CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

crConnectionInfo.DatabaseName = DatabaseName;
crConnectionInfo.Password = Password;
crConnectionInfo.UserID = UserID;
crConnectionInfo.ServerName = ServerName;

rptDocument.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName, False);

rptDocument.PrintOptions.PrinterName = PrinterName;

rptDocument.PrintToPrinter( 1, false, 0, 0);

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}


这篇关于Crystal Report在WPF中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆