重载解析失败,因为没有可访问的“参数"接受此数量的参数 [英] Overload resolution failed because no accessible 'Parameters' accepts this number of arguments

查看:35
本文介绍了重载解析失败,因为没有可访问的“参数"接受此数量的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 VB.net 应用程序从 2.0 升级到 4.6.

I have upgraded a VB.net application from 2.0 to 4.6.

我在一段代码中遇到以下错误

I am getting below error in the piece of code

System.MissingMemberException:重载解析失败,因为没有可访问的参数"接受此数量的参数.

System.MissingMemberException: Overload resolution failed because no accessible 'Parameters' accepts this number of arguments.

可能是什么问题?

Private Function MyFunction123(ByRef oXMLConfigData As XmlNodeList, ByRef oCmdCommandCol As ArrayList, ByVal iCmdCount As Integer, ByRef oReturnDataset As ReturnValues) As Boolean

    Dim iCount As Integer
    Dim iRetVal As Integer
    Dim oCNode As XmlNode       
    Dim retVal As Boolean = False

    iRetVal = oCmdCommandCol(iCmdCount).Parameters(oCNode.ChildNodes(iCount).Attributes("SPParameter").Value).Value
    oCNode.ChildNodes(iCount).InnerText = iRetVal
    oReturnDataset.ReturnValues.AddReturnValuesRow(oCNode.Attributes("Name").Value, oCNode.ChildNodes(iCount).Attributes("Name").Value, oCNode.ChildNodes(iCount).InnerText)
    retVal = True
End Function

函数被称为

If Not MyFunction123(oXMLConfigSteps, oCmdCollection, iCountCmd, oReturnDataset) Then
    'Statements
End If

推荐答案

我知道了.

Arraylist "oCmdCommandCol" 填充了多个 SqlCommand 对象,因此需要显式类型转换.我更改了如下代码并且它起作用了.希望能帮助到类似情况的人.

Arraylist "oCmdCommandCol" was filled with multiple SqlCommand objects hence and explicit type cast is required. I changed the code as below and it worked. Hope it will help someone in similar situation.

Private Function MyFunction123(ByRef oXMLConfigData As XmlNodeList, ByRef oCmdCommandCol As ArrayList, ByVal iCmdCount As Integer, ByRef oReturnDataset As ReturnValues) As Boolean

    Dim iCount As Integer
    Dim iRetVal As Integer
    Dim oCNode As XmlNode       
    Dim retVal As Boolean = False

'Changed code -Start-

    Dim cmd As SqlCommand
    cmd = New SqlCommand()
    cmd = CType(oCmdCommandCol(iCmdCount), SqlCommand)
    iRetVal =  cmd.Parameters(oCNode.ChildNodes(iCount).Attributes("SPParameter").Value).Value

'Changed code -End-

    oCNode.ChildNodes(iCount).InnerText = iRetVal
    oReturnDataset.ReturnValues.AddReturnValuesRow(oCNode.Attributes("Name").Value, 
    oCNode.ChildNodes(iCount).Attributes("Name").Value, oCNode.ChildNodes(iCount).InnerText)
    retVal = True
End Function

这篇关于重载解析失败,因为没有可访问的“参数"接受此数量的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆