Error printing crystal report in my c# app

Jose Melendez 6 Reputation points
2021-11-24T20:55:01.27+00:00

Hello,

I made a c# program with VS 2019 with crystal report for visual studio. All works well in my machine.

I'm installing in my client with Clickonce. But I having a problem in my client with this error:

System.TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. ---> 
System.TypeInitializationException: The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception. ---> System.IO.FileLoadException:
 Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at CrystalDecisions.Shared.SharedUtils..cctor()
   --- End of inner exception stack trace ---
   at CrystalDecisions.Shared.SharedUtils.get_CurrentControl()
   at CrystalDecisions.Shared.SharedUtils.GetEffectiveCulture()
   at CrystalDecisions.CrystalReports.Engine.CREngineRes.GetString(String name)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.CheckForCrystalReportsRuntime()
   at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
   --- End of inner exception stack trace ---
   at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor()
   at PatientTrackingSystem.MainWindow.<PrintReportAsync>d__143.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PatientTrackingSystem.MainWindow.<cmdPrintRouteSlip_Click>d__144.MoveNext()

For the file log4net, I changed the publish Status in the Application Files to "Include" but I still have the same error.

Then I installed the log4net NuGet Package in my application, remade the clickonce setup, and I still have the same error.

When I look in the my client machine, I see that file where clickonce install the application.

Any idea to fix that issue?

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,064 questions
Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Olaf Helper 47,441 Reputation points
    2021-11-25T07:58:04.64+00:00

    Error printing crystal report

    Crystal Reports isn't a Microsoft product, meanwhile it's owned by SAP, so better post to a more related forum, like
    https://community.sap.com/topics/crystal-reports
    http://www.crystalreportsbook.com/forum/default.asp

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.