BC30933: a resolução de sobrecarga de ligação tardia não pode ser aplicada a ' <procedurename> ' porque a instância de acesso é um tipo de interfaceBC30933: Latebound overload resolution cannot be applied to '<procedurename>' because the accessing instance is an interface type
O compilador está tentando resolver uma referência a uma propriedade ou um procedimento sobrecarregado, mas a referência falha porque um argumento é do tipo Object
e o objeto de referência tem o tipo de dados de uma interface.The compiler is attempting to resolve a reference to an overloaded property or procedure, but the reference fails because an argument is of type Object
and the referring object has the data type of an interface. O Object
argumento força o compilador a resolver a referência como associação tardia.The Object
argument forces the compiler to resolve the reference as late-bound.
Nessas circunstâncias, o compilador resolve a sobrecarga por meio da classe de implementação em vez de por meio da interface subjacente.In these circumstances, the compiler resolves the overload through the implementing class instead of through the underlying interface. Se a classe renomear uma das versões sobrecarregadas, o compilador não considerará que a versão é uma sobrecarga porque seu nome é diferente.If the class renames one of the overloaded versions, the compiler does not consider that version to be an overload because its name is different. Isso, por sua vez, faz com que o compilador ignore a versão renomeada quando ela pode ter sido a opção correta para resolver a referência.This in turn causes the compiler to ignore the renamed version when it might have been the correct choice to resolve the reference.
ID do erro: BC30933Error ID: BC30933
Para corrigir este erroTo correct this error
Use
CType
para converter o argumento deObject
para o tipo especificado pela assinatura da sobrecarga que você deseja chamar.UseCType
to cast the argument fromObject
to the type specified by the signature of the overload you want to call.Observe que ele não ajuda a converter o objeto de referência para a interface subjacente.Note that it does not help to cast the referring object to the underlying interface. Você deve converter o argumento para evitar esse erro.You must cast the argument to avoid this error.
ExemploExample
O exemplo a seguir mostra uma chamada para um procedimento sobrecarregado Sub
que causa esse erro no momento da compilação.The following example shows a call to an overloaded Sub
procedure that causes this error at compile time.
Module m1
Interface i1
Sub s1(ByVal p1 As Integer)
Sub s1(ByVal p1 As Double)
End Interface
Class c1
Implements i1
Public Overloads Sub s1(ByVal p1 As Integer) Implements i1.s1
End Sub
Public Overloads Sub s2(ByVal p1 As Double) Implements i1.s1
End Sub
End Class
Sub Main()
Dim refer As i1 = New c1
Dim o1 As Object = 3.1415
' The following reference is INVALID and causes a compiler error.
refer.s1(o1)
End Sub
End Module
No exemplo anterior, se o compilador permitisse a chamada para as s1
gravados, a resolução ocorreria por meio da classe c1
em vez da interface i1
.In the preceding example, if the compiler allowed the call to s1
as written, the resolution would take place through the class c1
instead of the interface i1
. Isso significa que o compilador não consideraria s2
porque seu nome é diferente no c1
, embora seja a opção correta, conforme definido pelo i1
.This would mean that the compiler would not consider s2
because its name is different in c1
, even though it is the correct choice as defined by i1
.
Você pode corrigir o erro alterando a chamada para uma das seguintes linhas de código:You can correct the error by changing the call to either of the following lines of code:
refer.s1(CType(o1, Integer))
refer.s1(CType(o1, Double))
Cada uma das linhas de código anteriores converte explicitamente a Object
variável o1
em um dos tipos de parâmetro definidos para as sobrecargas.Each of the preceding lines of code explicitly casts the Object
variable o1
to one of the parameter types defined for the overloads.