Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF CrystalReports
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.
Posted 19-Nov-12 3:20am
Edited 19-Nov-12 22:47pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
MahmutKoyuncu at 19-Nov-12 9:00am
   
Thanks for your response. It is not directly load from file path. I create report as an object. Can it be same problem again?
MahmutKoyuncu at 19-Nov-12 10:16am
   
I try to load from file path. Again same thing happened. I write file path to text file and it is correct. In the directory, the report exists, but again I face to face an error. I cannot find it :S
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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);
}
 
  Permalink  
Comments
Nelek at 19-Nov-12 13:35pm
   
Please don't post solutions to add information, to ask something or to comment another user.
- To add information to your message, you can use the widget "Improve question" / "Improve solution" at the bottom of your text.
- To ask/answer a user, you can use the widget "Have a question or comment?" (as I am doing right now with you) or the widget "reply" in another comment.
Jean-Claude ADIBA at 19-Nov-12 13:46pm
   
;) thank you for your precision
Nelek at 19-Nov-12 17:13pm
   
You are welcome
MahmutKoyuncu at 19-Nov-12 17:52pm
   
yes AppDomain.CurrentDomain.BaseDirectory + @"ReportFolder\ReportName.rpt"; works too but path correct I check and report is in the directory. And the code is in try-catch block.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 205
1 Richard MacCutchan 185
2 DamithSL 170
3 Tomas Takac 146
4 OriginalGriff 132
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100