We've got an ASP.NET project in c# (Visual Studio 2015). As part of the application, we have included a couple of canned Crystal Reports designed in the Crystal plugin for VS 2015. On the local dev machine, we can run the reports no problem using the code below.
using CrystalDecisions.CrystalReports.Engine;
...
ReportDocument report = new ReportDocument();
TableLogOnInfo conInfo = new TableLogOnInfo();
conInfo.ConnectionInfo.UserID = Global.Config.GetValue("USERID");
conInfo.ConnectionInfo.Password = Global.Config.GetValue("PASSWORD");
conInfo.ConnectionInfo.DatabaseName = Global.Config.GetValue("DATABASENAME");
conInfo.ConnectionInfo.ServerName = Global.Config.GetValue("DATASOURCE");
report.Load(reportPath + name);
for (int i = 0; i < report.Database.Tables.Count; i++)
{
report.Database.Tables[i].ApplyLogOnInfo(conInfo);
}
return new FileStreamResult(report.ExportToStream(ExportFormatType.PortableDocFormat), "application/pdf");
But when we deploy to the IIS Server on a Windows 2008 Server r2 machine, we get an error while instantiating the ReportDocument object:
at CrystalDecisions.Shared.SharedUtils..cctor() :
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
All of the CrystalDecisions.*.dlls are included in the published app. I'm pulling my hair out trying to figure out what is wrong.
To be clear, we are not using the Crystal Viewer. We are just trying to run a report (*.rpt) and output to a PDF filestream.
I copied the log4net.dll from my local machine to get past the first error. Apparently, you need to install a crystal runtime as well. But runtime would not install on the Windows 2008 r2 SP1 server. It failed when registering some of the DLLs.
We were able to get and older version (CRRuntime_32bit_13_0_19) to install. But this had issues with the compiled code.
I needed to apply some Microsoft updates in order to finally get the CRRuntime_32bit_13_0_23 runtime to install. Once this runtime was installed, everything was fine.
The documentation is not very clear. Nor does there appear to be any easy way to find a list of prerequisites for the proper runtime. I have no idea which MS Update was required. I just installed a bunch of them. This server had been locked down to updates prior to this because it had been stable for several years.
Lesson learned.