为什么数据源中没有数据对象? (数据源配置向导)

Why are there no data objects in data sources? (Data Source Configuration Wizard)

我的申请基于 Windows 表格。我正在使用 RDLC(版本 15.3.1)创建报告。该报告应该有一个 table,其中填充了我从 DataGridView 中获取的数据。

从DataGridView向报表传输数据如下。

List<OriginalPredicted> op = new List<OriginalPredicted>();
                            op.Clear();
                            for (int i = 0 ; i < mp.predResultsGridView.Rows.Count; i++)
                            {
                                op.Add(new OriginalPredicted { Original = (double)mp.predResultsGridView.Rows[i].Cells[0].Value, Predicted = (double)mp.predResultsGridView.Rows[i].Cells[1].Value });
                            }
                            ReportDataSource rds = new ReportDataSource("Dataset_Orig_Pred", op);
                            reportViewer.LocalReport.DataSources.Clear();
                            reportViewer.LocalReport.DataSources.Add(rds);
                            reportViewer.LocalReport.Refresh();

在此之前,我创建了一个包含 class 个实例的列表。 Class实现如下:

    public class OriginalPredicted
    {
        public double Original { get; set; }
        public double Predicted { get; set; }
    }

问题是当我想添加一个数据集和select一个对象作为数据源时,找不到任何class (业务对象)在 "Select the data objects" window 中使用。项目树下只有 "Properties" 项,但我希望还能看到我创建的 classes。 Image of "Select the data objects" window

我尝试了什么:

  1. 正在将编译选项更改为 x86。我猜 RDLC 在 x86 环境下运行良好,所以 x64 依赖项存在问题。 没用。 此处提供了解决方案:Class (Business Object) not appearing in Report Data toolbox for RDLC
  2. 重建项目解决方案。 没有改变。
  3. 正在重新启动 Visual Studio。 仍然没有运气。

项目中存在严格针对 x64 体系结构的依赖项是否会影响数据源配置向导的行为?

我的项目使用版本控制系统。会不会也有影响?

此外,我尝试在干净的项目上重现该问题。在这种情况下,一切正常。不幸的是,我无法在其他地方重做该项目,因为它非常耗时。 Image of "Select the Data Objects" window after reproducing issue

谢谢。

我尝试过的第一个解决方案并不是它看起来的样子。我只是在摆弄配置管理器,这是不对的。答案隐藏得很好。所以它与RDLC的位数有关。一般来说,真正的解决方案是在项目属性 "Target Platform" 中设置为 "Any CPU" 或 "x86" 如果它设置为 "x64" 并检查 "Prefer 32-bit" 是否被选中。 Image of "Project Properties"