c# - 在 Crystal Report 中分配 DataSource 时发生 FileNotFoundException

标签 c# crystal-reports visual-studio-2013 filenotfoundexception

在报告中分配数据源时抛出 System.IO.FileNotFoundException 异常。 我正在使用 visual studio 2013、C# 4.5、WinForm 应用程序。我已经为 Visual Studio 13 安装了 Crystal Report。

这是代码

    DataSet ds = new DataSet();
    ds.Tables.Add(new DataTable("administration_CashDeskManager_Reports_ReportDataBusinessObject"));
    ds.Tables.Add(new DataTable("administration_CashDeskManager_Reports_ReportDataDetailBusinessObject"));

    Reports.CrystalReport.rptCashDeskTransactionLog Report = new Reports.CrystalReport.rptCashDeskTransactionLog();
    Report.SetDataSource(ds);
    crViewer.ReportSource = Report;

Report.SetDataSource(ds) 命令引发错误。

我认为这个错误是特定于版本的错误。

异常详细信息:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

最佳答案

在您的配置中添加以下部分后重试:

<startup uselegacyv2runtimeactivationpolicy="true">
  <supportedruntime version="v4.0" />
</startup>

关于c# - 在 Crystal Report 中分配 DataSource 时发生 FileNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23774260/

相关文章:

c# - ASP.NET Core 2 - 全局过滤器注册多种方式?

c# - XDocument 加载到 ToList

c# - 协调工作线程关闭

crystal-reports - Visual Studio 2015 社区中的 Crystal Reports

c# - VS2013 调试器 + Entity Framework : "runtime has refused to evaluate the expression", 崩溃

c# - 使用 Visual Studio 和 C# 仅捕获正则表达式中的整个单词

c# - 没有页面扩展的 URL 重写规则

database - 是否有一种报表或交叉表可以优雅地显示这些数据?

crystal-reports - Crystal 报表 : formula for Splitting string on/and concatenating it with other string

visual-studio-2013 - MVC 5 - 预编译 View 仅适用于命令提示符