Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. COM Interop between C++ program and VB.NET DLL

COM Interop between C++ program and VB.NET DLL

Scheduled Pinned Locked Moved Visual Basic
comtutorialcsharpc++
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _obi_
    wrote on last edited by
    #1

    Hi everyone out there :) I have a problem (in the VERY beginning state) of writing a VB.NET DLL that will be used as a plugin for a C++ Program. I try to outline what the goal is... There is a videochat program called CamFrog. For this a Bot (for managing the chatroom) is available that uses plugins. The Bot comes with a C++ sample for a simple plugin. What i want to do is to "translate" that into a VB.NET Version (because C++ is really not my thing... i hardly figured out how the sample might work). Now... I know that a .NET DLL is not the same as the C++ DLLs that are used by the bot but i guess it should be possible to achieve the same with COM Interop... I hope I'm right. Now I looked on the sample plugin with dependency walker and it exports a few functions that will be called by the bot-program. My first step now is to try to build a dll in VB.NET (2010 express) that ecports one simple function... i just want to see the function in dependency walker for now. What i did so far: I followed the guide from MS (Walkthrough: Creating COM Objects with Visual Basic[^]) using the part "Creating COM Objects without the COM Class Template " (and some other hints from different pages i found). All settings are ok as far as i can see and my "code" is as follows:

    Imports System.Runtime.InteropServices

    _
    Public Class ComClass1
    Public Const ClassId As String = "C4889882-ECC6-4BBE-9B65-A9DCC30B90F8"
    Public Const InterfaceId As String = "6420CC9C-2B69-4DFD-A149-C694895D80BD"
    Public Const EventsId As String = "0A0ACD71-7651-4BE5-9128-FE8AECCAE623"

    Public Sub New()
        MyBase.New()
    End Sub
    
    \_
    Public Function testfunction() As Boolean
        Return True
    End Function
    

    End Class

    As far as I understood "testfunction" should now be visible as an exported function of the DLL in dependency walker... But... it doesn't appear (list of exported functions is empty). The whole thing with COM-Interop and that stuff is completely new for me and I barely understood all the things I read during the last 5 or 6 hours googling... so I'm sure that I miss something on it. I hope someone can kick me in the right direction. Thanks in advance -obi-

    B 1 Reply Last reply
    0
    • _ _obi_

      Hi everyone out there :) I have a problem (in the VERY beginning state) of writing a VB.NET DLL that will be used as a plugin for a C++ Program. I try to outline what the goal is... There is a videochat program called CamFrog. For this a Bot (for managing the chatroom) is available that uses plugins. The Bot comes with a C++ sample for a simple plugin. What i want to do is to "translate" that into a VB.NET Version (because C++ is really not my thing... i hardly figured out how the sample might work). Now... I know that a .NET DLL is not the same as the C++ DLLs that are used by the bot but i guess it should be possible to achieve the same with COM Interop... I hope I'm right. Now I looked on the sample plugin with dependency walker and it exports a few functions that will be called by the bot-program. My first step now is to try to build a dll in VB.NET (2010 express) that ecports one simple function... i just want to see the function in dependency walker for now. What i did so far: I followed the guide from MS (Walkthrough: Creating COM Objects with Visual Basic[^]) using the part "Creating COM Objects without the COM Class Template " (and some other hints from different pages i found). All settings are ok as far as i can see and my "code" is as follows:

      Imports System.Runtime.InteropServices

      _
      Public Class ComClass1
      Public Const ClassId As String = "C4889882-ECC6-4BBE-9B65-A9DCC30B90F8"
      Public Const InterfaceId As String = "6420CC9C-2B69-4DFD-A149-C694895D80BD"
      Public Const EventsId As String = "0A0ACD71-7651-4BE5-9128-FE8AECCAE623"

      Public Sub New()
          MyBase.New()
      End Sub
      
      \_
      Public Function testfunction() As Boolean
          Return True
      End Function
      

      End Class

      As far as I understood "testfunction" should now be visible as an exported function of the DLL in dependency walker... But... it doesn't appear (list of exported functions is empty). The whole thing with COM-Interop and that stuff is completely new for me and I barely understood all the things I read during the last 5 or 6 hours googling... so I'm sure that I miss something on it. I hope someone can kick me in the right direction. Thanks in advance -obi-

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Does the example provided by the manufacturer use COM? Well, then your idea of COM interop will be feasable. Otherwise you should know that C++ does not mean COM! If the interface is defined with C++ header files (*.h), then you'll have to write a mixed mode (managed + unmanaged) dll in C++ which in turn can call your VB.Net dll. That is possible, but not at all easy when you do not yet understand the concepts.

      _ 1 Reply Last reply
      0
      • B Bernhard Hiller

        Does the example provided by the manufacturer use COM? Well, then your idea of COM interop will be feasable. Otherwise you should know that C++ does not mean COM! If the interface is defined with C++ header files (*.h), then you'll have to write a mixed mode (managed + unmanaged) dll in C++ which in turn can call your VB.Net dll. That is possible, but not at all easy when you do not yet understand the concepts.

        _ Offline
        _ Offline
        _obi_
        wrote on last edited by
        #3

        Bernhard Hiller wrote:

        Otherwise you should know that C++ does not mean COM!

        I knew it sounded to easy to me...

        Bernhard Hiller wrote:

        If the interface is defined with C++ header files (*.h), then you'll have to write a mixed mode (managed + unmanaged) dll in C++ which in turn can call your VB.Net dll

        There is a bunch of header files... but I have no idea how to do this "wrapper dll" in c++... also it's neccessary that my dll in turn calls functions of the c++ program (or it's dlls). Would it be possible to do what i want using VB6 instead of vb.net? In the documentation they mentioned (in one sentence) Visual Basic and Delphi as possible languages. I never used VB6 before (stopped using VB at VB3 and restarted with VB.NET 2010) but i think that will be much easier for me than learning C++ from scratch. Anyway thanks for your answer Bernhard... even if I'm not really happy with my new knowledge ;)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups