Udostępnij za pośrednictwem


Cannot implement '<interfacename1>.<membername>' because its implementation could conflict with the implementation for '<interfacename2>.<membername>' for some type arguments

A class implements more than one generic interface, one of which inherits from another, and two implementations of an interface member could conflict for certain values of type arguments.

The following statements can generate this error.

Public Interface iFace1(Of t)
    Sub testSub()
End Interface
Public Interface iFace2(Of u)
    Inherits iFace1(Of u)
End Interface
Public Class testClass(Of y, z)
    Implements iFace1(Of y), iFace2(Of z)
    Public Sub testSuby() Implements iFace1(Of y).testSub
    End Sub
    Public Sub testSubz() Implements iFace1(Of z).testSub
    End Sub
End Class

Because iFace2 inherits from iFace1 using its own type parameter (u), testClass would implement two versions of iFace1.testSub with identical signatures if the same type argument were passed to y and z. This would produce an ambiguity about which version to access.

Error ID: BC32125

To correct this error

  • Change the inheritance structure of the interfaces so that iFace1 could not be implemented with two different type arguments.

    -or-

  • Remove from the Implements statement one of the interfaces resulting in the implementation conflict.

See Also

Concepts

Implements Keyword and Implements Statement

Generic Types in Visual Basic

Reference

Class Statement (Visual Basic)

Interface Statement (Visual Basic)

Implements Statement