【问题标题】:Error printing crystal report in my c# app在我的 C# 应用程序中打印水晶报告时出错
【发布时间】:2022-01-03 05:32:44
【问题描述】:

我用 VS 2019 为 Visual Studio 制作了一个带有水晶报表的 c# 程序。在我的机器上一切正常。

我正在使用 Clickonce 在我的客户端中进行安装。但是我的客户遇到了这个错误:

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()

对于文件 log4net,我将应用程序文件中的发布状态更改为“包含”,但仍然出现相同的错误。

然后我在我的应用程序中安装了 log4net NuGet 包,重新进行了 clickonce 设置,但我仍然有同样的错误。

当我查看我的客户端计算机时,我看到 clickonce 安装应用程序的那个文件。

有解决这个问题的想法吗?

【问题讨论】:

    标签: log4net


    【解决方案1】:

    您在加载用于附加日志的文件时遇到问题,请提及您遵循的步骤并确保您的配置文件和程序集文件正确,大部分问题是由于您的配置文件造成的。

    1. 你必须去 AssemblyInfo.cs 并包含

      [程序集:log4net.Config.XmlConfigurator(Watch = true)]

    2. 你必须确保在你的配置文件中这个标签下的文件路径是正确的:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多