Error using Crystal Reports for .net

I wrote a program that generates PDF files from Crystal Report, and then sends these PDF files to someone. The program works fine on my development machine, but when I copy the bin \ Release directory to Windows 2000 Server (the machine on which I want to run it), it starts and then generates this error and a stack trace:

The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor() at DailyJobCostSummaryEmail.Program.crptToPDF(String reportFile, String jobNum, String outputLocation) in M:\Projects\DailyJobCostSummaryEmail\DailyJobCostSummaryEmail\Program.cs:line 79 at DailyJobCostSummaryEmail.Program.Main(String[] args) in M:\Projects\DailyJobCostSummaryEmail\DailyJobCostSummaryEmail\Program.cs:line 46 

ERROR VIEW ANYWHERE, EXCEPT WHEN CONTINUING FROM A VISUAL STUDIO.

.Net 2.0 is installed on this computer, and since then I installed CRRedist2005_x86.msi without effect. I even got the "Send error message to Microsoft" dialog box, although I use try / catch to print the exception to the file. Even when the catch block is executed, my program will not close properly.

 static void Main(string[] args) { try { String dir = @"JobCostReports"; DataTable jobs = new DataTable(); using (SqlConnection conn = new SqlConnection(connString)) { String sql = "JC_GetJobsClosedYesterday"; SqlDataAdapter da = new SqlDataAdapter(sql, conn); da.Fill(jobs); } List<String> files = new List<String>(); foreach (DataRow row in jobs.Rows) { files.Add(crptToPDF(@"JobCost.rpt", row["JobNumber"].ToString().TrimEnd(), dir)); } Utilities.sendEmail("[toEmail]", "[FromEmail]", "Job Cost Summaries for Yesterday", "Attached are Job cost summaries for the " + files.Count + " jobs closed yesterday.", files.ToArray()); Console.WriteLine("Email sent."); } catch (Exception e) { using (StreamWriter writer = new StreamWriter("errors.log", true)) { writer.AutoFlush = true; Console.WriteLine(); writer.WriteLine(e.Message); writer.WriteLine(e.StackTrace); } Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Console.Read(); } finally { } } public static String crptToPDF(String reportFile, String jobNum, String outputLocation) { using (ReportDocument rpt = new ReportDocument()) { rpt.Load(reportFile); rpt.SetParameterValue("@vJobNumber", jobNum); String output = outputLocation + @"\" + jobNum + "_JobCostSummary.pdf"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, output); return output; } } 

I do not include all the correct references and use of statements? I tried many combinations, but no effect.

+6
c # crystal-reports console-application
source share
6 answers

It could also be a problem with the fact that the CR assemblies that came with the visual studio are a different version for the full product.

If you are having problems downloading downloads from business objects, try running here:

https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=56787567

+2
source share
0
source share

Ensure that the configurations of the debugging and release solutions in Visual Studio have the same dependencies and settings, and that all dependency paths are relative; when something works in VS but not outside, I usually find that this is one of those towing issues.

0
source share

A quick and dirty trick. Hope this works.

AFAI can understand, maybe there are no shortcomings of the referees at the release of the product or in the mistmatch version. For this to happen, from your decision, go to the directory of reference materials β†’ Choose a link-> Right-click on the link β†’ Select a property β†’, then select Copy local - True. Now create the application and copy the new bin directory and pages into production and make sure that it works or not. If it still does not work, then again go to the link property, select the path. If it is in the GAC, then do a Google search to copy the dll from the GAC. Or you can copy your Windows folder to the same computer and gain access, then go through the directory and copy the DLL, but for this you need admins. Now create a new dir inside the solution, name it CRDist, insert all the DLLs inside the folder and go from there to the end of production, open the command line and register the DLL using the path dll regsvr32 -i.

ALSO IN YOUR EXPORT MECHANISM PDF,

I see that you are loading a report file, but not using any data source. You set the data source at design time or what happens behind the scanners.

Hope this helps

0
source share

Register a managed assembly. Use it

 C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>RegAsm.exe /tlb dllName.dll Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. Here v1.1.4322 will the framework you are developing. Choose the framework accordingly. Or goto Start->AllPrograms -> MicrosoftVisual Studio 2005/8/10-> Visual Studio Tools-> Visual Studio Command Prompt. then run RegAsm.exe /tlb dllName.dll 
0
source share

The server is incorrectly configured, I'm afraid. Reinstall the runtime on it from SAP (NOT VS), which you can find by search query. When you say that you want to run it on the server, are you running it as a website or is it that you drop the RPT to a network resource or what? If this is a website, then this is, without a doubt, a misconfigured Crystal on the server - not your report as such.

I don’t think, but I don’t know for sure that setting the runtime will ask you about the product key at any time, since you just use the free viewer, etc. If you receive a request for a product key, then you do not set a pure battery life, I am afraid.

0
source share

All Articles