Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have to implement a COM class with VB.NET. An object of this class has then to be created from a VB6 DLL. The code for the COM dll is very simple:
VB
Public Class AdapterWrapper
    Implements SchemaCompInterfaces.IEFAdapter

#Region "COM-GUIDs"
    Public Const ClassId As String = "58faad86-bbac-4b20-9ab5-fe32bdac0a68"
    Public Const InterfaceId As String = "f8dbb078-5f1e-4304-a390-3e8e88983f98"
    Public Const EventsId As String = "113d2163-f8db-4d99-88e5-58d13b8d2cf4"
#End Region
   
    Public Sub New()
        MyBase.New()
    End Sub
    Public WriteOnly Property CurrentSPFProjectStatus() As SchemaCompInterfaces.SPFProjectStatus Implements SchemaCompInterfaces.IEFAdapter.CurrentSPFProjectStatus
        Set(ByVal value As SchemaCompInterfaces.SPFProjectStatus)
        End Set
    End Property
    Public Function DocumentExistsInTool(ByRef oDocumentIObj As SchemaCompInterfaces.IObject) As Boolean Implements SchemaCompInterfaces.IEFAdapter.DocumentExistsInTool
    End Function


Following many more functions from the IEFAdapter interface...
The dll and tlb are created and registered.

The test code for the VB6 client to use this COM class is also very simple:
VB
Private Sub Command1_Click()
  Dim adapter As SchemaCompInterfaces.IEFAdapter
  Set adapter = Interaction.CreateObject("MyEFAdapter.AdapterWrapper")    
End Sub


Now when I'm running this code, I'm getting the Run-time error '13' Type mismatch in the CreateObject line. Late binding with
Dim adapter as Object
seems to work for my test code, but is not a solution for me, because I can't change the proprietary VB6 code where the COM object is created. So somehow the interface "SchemaCompInterfaces.IEFAdapter" is not known... :sigh:

Any ideas how to get close to this problem?
In the project properties I checked the flag for registration with COM-Interop. Perhaps something to do with the ClassInterface?

I'm relatively new to VB, so don't answer too complex... ;)

Thanks in advance!
Alex
Posted

1 solution

Perhaps you need to Check "Register COM Interop" Checkbox in Compile option in project properties.

This will register the type library of your project and can be used in VB6
 
Share this answer
 
Comments
AlexInter 19-Jul-10 8:08am    
Unfortunately I checked this property in the Compile options.

(Added this almost at the end of my question, maybe I should have written this at the beginning...)
Goutam Patra 19-Jul-10 8:13am    
Is there a MyEFAdapter.TLB file in your Debug Folder
Then You need to register it also
You can do it manually using
REGASM /unregister <dllname> /tlb <tlbname> in the command prompt
REGASM /register <dllname> /tlb <tlbname> in the command prompt

And then you can add referrence to your VB6 Project of that TLB file.

Hope this will help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900