How to create a VB.NET COM-visible interface without IDispatch?

315 views Asked by At

If I create a COM-visible VB.NET interface, such as:

<ComVisible(True)>
Public Interface IMyInterface
    Sub MyMethod()
End Interface

Then the resulting type library will show IMyInterface inheriting IDispatch. Is there a way to inherit just IUnknown, and not IDispatch?

1

There are 1 answers

0
Simon Mourier On BEST ANSWER

Use the InterfaceTypeAttribute Class like this:

<ComVisible(True), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IMyInterface
    Sub MyMethod()
End Interface