Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误:";以下方法或属性之间的调用不明确";?_C#_Report_Reporting - Fatal编程技术网

C# 错误:";以下方法或属性之间的调用不明确";?

C# 错误:";以下方法或属性之间的调用不明确";?,c#,report,reporting,C#,Report,Reporting,运行项目时,将显示以下错误消息: 以下方法或属性之间的调用不明确:“Microsoft.Reporting.WinForms.ReportDataSource.ReportDataSource(string,System.Collections.IEnumerable)”和“Microsoft.Reporting.WinForms.ReportDataSource.ReportDataSource(string,System.Data.DataTable)” 为什么? 从错误消息中可以明显看出,

运行项目时,将显示以下错误消息:

以下方法或属性之间的调用不明确:“Microsoft.Reporting.WinForms.ReportDataSource.ReportDataSource(string,System.Collections.IEnumerable)”和“Microsoft.Reporting.WinForms.ReportDataSource.ReportDataSource(string,System.Data.DataTable)”

为什么?


从错误消息中可以明显看出,类型
dsFirstReport.dtLoaiHangDataTable
继承了
DataTable
类型并实现了
IEnumerable

您可以通过将参数强制转换为一个或另一个来解决编译器的歧义。例如:

reportViewer1.LocalReport.DataSources.Add(
    new ReportDataSource("dsFirstReport_DataSet1", (IEnumerable)dt));

dsFirstReport.dtLoaiHangDataTable
实现了哪些类型?dsFirstReport.dtLoaiHangDataTable是否继承了
DataTable
并实现了
IEnumerable
?如果是这样,这就是为什么它不知道选择哪个。dsFirstReport是表LoaiHang的数据集您可以发布dsFirstReportClass的实现吗?
reportViewer1.LocalReport.DataSources.Add(
    new ReportDataSource("dsFirstReport_DataSet1", (IEnumerable)dt));