方法“<methodname>”没有与委托“<delegatename>”兼容的签名

更新:2007 年 11 月

当需要在方法和委托之间进行不可能的转换时,发生此错误。错误原因可能是在参数之间进行的转换或在返回值之间进行的转换(当方法和委托是函数时)。

下面的代码阐释失败的转换。委托为 FunDel。

Delegate Function FunDel(ByVal i As Integer, ByVal d As Double) As Integer

下面的函数各自以将要导致此错误的方式区别于 FunDel。

Function ExampleMethod1(ByVal m As Integer, ByVal aDate As Date) As Integer
End Function

Function ExampleMethod2(ByVal m As Integer, ByVal aDouble As Double) As Date
End Function

下面的每个赋值语句都将导致该错误。

Sub Main()
    ' The second parameters of FunDel and ExampleMethod1, Double and Date,
    ' are not compatible.
    'Dim d1 As FunDel = AddressOf ExampleMethod1

    ' The return types of FunDel and ExampleMethod2, Integer and Date,
    ' are not compatible.
    'Dim d2 As FunDel = AddressOf ExampleMethod2

End Sub

**错误 ID:**BC31143

更正此错误

  • 检查相应的参数,并且在参数存在的情况下返回类型以确定哪对不兼容。

请参见

概念

宽松委托转换

委托和 AddressOf 运算符