简体   繁体   English

重载解析失败,因为对于这些参数,没有可访问的“新”是最具体的

[英]Overload resolution failed because no accessible 'new' is most specific for these arguments

This is the code: 这是代码:

If ComboBox1.Text = "Total profil for all time" Then

        Dim TA As New CPDBTableAdapters.TotalProfilForAllTimeTableAdapter
        Dim TmpDS As New CPDB
        TA.Fill(TmpDS.TotalProfilForAllTime)


        'obriši prošli DS
        RV.LocalReport.DataSources.Clear()

        'dodaj novi DS
        Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", TmpDS.TotalProfilForAllTime)
        RV.LocalReport.DataSources.Add(RDS)
        RV.LocalReport.ReportEmbeddedResource = "change_password.report1.rdlc"
        RV.RefreshReport()


    End If

Problem is here: 问题在这里:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", 
    TmpDS.TotalProfilForAllTime)

Error message: overload resolution failed because no accessible 'new'is most specific for these arguments. 错误消息:重载解析失败,因为对于这些参数,没有可访问的“新”是最特定的。

Depending on the type of TmpDS.TotalProfilForAllTime, cast the second argument passed to the constructor: 根据TmpDS.TotalProfilForAllTime的类型,强制转换传递给构造函数的第二个参数:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, DataTable))

or: 要么:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, IEnumerable))

etc. 等等

VB can't clearly pick the best constructor overload, so you have to provide some help to the compiler. VB无法清楚地选择最佳的构造函数重载,因此您必须为编译器提供一些帮助。 See this link for the possible 2nd argument types expected. 有关可能的第二个参数类型的信息,请参见此链接。 http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx This is a common problem in VB code since VB is not very strict about interpreting object types - it allows more variation in allowing one object type being used in place of another (especially with Option Strict Off). http://msdn.microsoft.com/zh-cn/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx这是VB代码中的常见问题,因为VB在解释方面不是很严格对象类型-在允许使用一种对象类型代替另一种对象类型时(尤其是在Option Strict Off下),它允许更多的变化。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 重载解析失败,因为没有可访问的“新”是这些参数最具体的: - Overload resolution failed because no accessible 'New' is most specific for these arguments: 重载解析失败,因为没有可访问的“ DataBind”最特定于这些参数 - overload resolution failed because no accessible 'DataBind' is most specific for these arguments 重载解析失败,因为没有可访问的“新”接受此数目的参数 - overload resolution failed because no accessible 'new' accepts this number of arguments 尝试将stringbuilder文本写入批处理文件时,“由于没有可访问的'New'接受此数目的参数,所以过载解析失败” - “Overload resolution failed because no accessible 'New' accepts this number of arguments” when trying to write stringbuilder text into a batch file 重载解析失败,因为没有可访问的'writealltext'接受此数量的参数 - overload resolution failed because no accessible 'writealltext' accepts this number of arguments 重载解析失败,因为没有可访问的“参数”接受此数量的 arguments - Overload resolution failed because no accessible 'Parameters' accepts this number of arguments 重载解析失败,因为没有可访问的“ ExecuteScalar”接受此数量的参数 - Overload resolution failed because no accessible 'ExecuteScalar' accepts this number of arguments 重载解析失败,因为无法使用这些参数调用可访问的“睡眠” - Overload resolution failed because no accessible `Sleep` can be called with these arguments 重载解决失败,因为无法使用这些参数调用可访问的“加入” - Overload resolution failed because no accessible 'Join' can be called with these arguments 超载解析失败,因为无法访问“项目” - Overload resolution failed because no 'item' is accessible
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM