I have a C # project with a common interface
public interface IMyFoo<T> { void DoSomething(T instance); }
I also have a C # project with an interface that inherits from several IMyFoos
public interface IMyBar : IMyFoo<Type1>, IMyFoo<Type2> { ... }
Everything works fine in C # ground (including the script below that doesn't work in VB).
I have a VB.NET project that references this C # library.
I have an instance of IMyBar and am trying to use it as follows:
Dim instance as MyType1 = ... Dim bar as IMyBar = ... bar.DoSomething(instance) ' This generates a compile error: ' 'DoSomething' is ambiguous across the inherited interfaces 'IMyFoo(Of MyType1)' and 'IMyFoo(Of MyType2)'.
What? I can DirectCast like this, and it works fine ... but I REALLY probably don't
DirectCast(bar, IMyFoo(Of MyType1)).DoSomething(instance)
source share