I have a com dll written in c# After running Regasm I can call this dll from VB6, referencing the com dll. In VB6 I have intellisense available.
However when I press F5 to compile the compiler does not catch any mistakes in calling the com dll. It must be using late binding.
How can I get it to use early binding?
The interface is declared
using System.Runtime.InteropServices;
namespace combridge
{
[Guid("2f4b6041-91e3-4d9f-a9f5-9bd4adfd1789")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IBridge
{
// methods go here
}
}
The main class is declared
[Guid("085777fa-9397-4cfd-843a-85ececb86789")]
[ProgId("companyname.ComBridge")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class BridgeImplementation : IBridge
{
#region Public Implementation
[DispId(1)]
[ComVisible(true)]
public string EchoTest(string message)
{
return string.Format("Echo '{0}' at {1:T}", message, DateTime.Now);
}
// etc
[update]
In the VB6 project I reference the tlb file which I create using
c:\WINDOWS\Microsoft.Net\Framework\v4.0.30319/regasm /verbose /codebase /tlb:CommBridge.tlb ComBridge.dll
In the VB6 I create the object using
Dim o As BridgeImplementation
Set o = New BridgeImplementation
o.EchoTest // executes
o.NonExistantFunction // run time error
Above the interface declaration I replaced
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
with
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
and it solved the problem