VB 6 Com Interop question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan Dickerson

    #1

    VB 6 Com Interop question

    I'm writing a DLL for which I want to expose a COM interface. I found the
    check box on the Configuration to do that. So I built the solution, got
    into my VB6 project, added the reference and started adding code, but there
    was no intellisense, no properties, nothing. What did I do wrong?

    --
    TFWBWY...A


  • Josip Habjan

    #2
    Re: VB 6 Com Interop question

    Hi,

    Set class ComClass attribute... and add ClassId, InterfaceId and EventsId
    constant to your class.
    In each class create new GUIDs for each of this three constants.

    See sample below how i do it:

    ############### ############### ############### ############### ############
    Option Explicit On
    Option Strict On

    Imports System.Text.Enc oding
    Imports System.Runtime. InteropServices

    <ComClass(Helpe r.ClassId, Helper.EventsId , Helper.Interfac eId)> _
    Public Class Helper

    #Region " COM GUIDs "

    Public Const ClassId As String = "6C1967B7-4EC8-4b70-BA94-C131EE892452"
    Public Const InterfaceId As String =
    "4CDC9471-D4E2-4824-BD4D-938EF299D58C"
    Public Const EventsId As String = "4D18D7F1-BC51-49f0-824B-69F607EBD3B2"

    #End Region

    Sub New()
    End Sub

    Public Function UTF8BytesToStri ng(ByVal buffer() As Byte) As String
    If Not buffer Is Nothing Then
    Return UTF8.GetString( buffer)
    Else
    Return String.Empty
    End If
    End Function

    Public Function UTF8StringToByt es(ByVal text As String) As Byte()
    Return UTF8.GetBytes(t ext)
    End Function

    End Class
    ############### ############### ############### ############### ############

    I hope it helps.


    "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
    news:u$Hisn2dFH A.3452@tk2msftn gp13.phx.gbl...[color=blue]
    > I'm writing a DLL for which I want to expose a COM interface. I found the
    > check box on the Configuration to do that. So I built the solution, got
    > into my VB6 project, added the reference and started adding code, but
    > there was no intellisense, no properties, nothing. What did I do wrong?
    >
    > --
    > TFWBWY...A
    >[/color]


    Comment

    • Bryan Dickerson

      #3
      Re: VB 6 Com Interop question

      How do I get the GUIDs?

      "Josip Habjan" <jhabjan@spamof f-net.hr> wrote in message
      news:d9cj31$erf $1@magcargo.vod atel.hr...[color=blue]
      > Hi,
      >
      > Set class ComClass attribute... and add ClassId, InterfaceId and EventsId
      > constant to your class.
      > In each class create new GUIDs for each of this three constants.
      >
      > See sample below how i do it:
      >
      > ############### ############### ############### ############### ############
      > Option Explicit On
      > Option Strict On
      >
      > Imports System.Text.Enc oding
      > Imports System.Runtime. InteropServices
      >
      > <ComClass(Helpe r.ClassId, Helper.EventsId , Helper.Interfac eId)> _
      > Public Class Helper
      >
      > #Region " COM GUIDs "
      >
      > Public Const ClassId As String = "6C1967B7-4EC8-4b70-BA94-C131EE892452"
      > Public Const InterfaceId As String =
      > "4CDC9471-D4E2-4824-BD4D-938EF299D58C"
      > Public Const EventsId As String =
      > "4D18D7F1-BC51-49f0-824B-69F607EBD3B2"
      >
      > #End Region
      >
      > Sub New()
      > End Sub
      >
      > Public Function UTF8BytesToStri ng(ByVal buffer() As Byte) As String
      > If Not buffer Is Nothing Then
      > Return UTF8.GetString( buffer)
      > Else
      > Return String.Empty
      > End If
      > End Function
      >
      > Public Function UTF8StringToByt es(ByVal text As String) As Byte()
      > Return UTF8.GetBytes(t ext)
      > End Function
      >
      > End Class
      > ############### ############### ############### ############### ############
      >
      > I hope it helps.
      >
      >
      > "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
      > news:u$Hisn2dFH A.3452@tk2msftn gp13.phx.gbl...[color=green]
      >> I'm writing a DLL for which I want to expose a COM interface. I found
      >> the check box on the Configuration to do that. So I built the solution,
      >> got into my VB6 project, added the reference and started adding code, but
      >> there was no intellisense, no properties, nothing. What did I do wrong?
      >>
      >> --
      >> TFWBWY...A
      >>[/color]
      >
      >[/color]


      Comment

      • Josip Habjan

        #4
        Re: VB 6 Com Interop question

        "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
        news:e4n5N$2dFH A.3032@TK2MSFTN GP10.phx.gbl...[color=blue]
        >
        > How do I get the GUIDs?
        >[/color]

        Menu:
        Tools->Create GUID

        .... and also .. each class you want to expose must have constructor with no
        parameters ....

        Regards,
        Josip Habjan
        URL: http://www.habjansoftware.com


        Comment

        • Bryan Dickerson

          #5
          Re: VB 6 Com Interop question

          It works!! Now if I can just get the .Net part working correctly I'll be
          flying!
          Thanx!

          "Josip Habjan" <jhabjan@spamof f-net.hr> wrote in message
          news:d9cl1i$ru1 $1@magcargo.vod atel.hr...[color=blue]
          > "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
          > news:e4n5N$2dFH A.3032@TK2MSFTN GP10.phx.gbl...[color=green]
          >>
          >> How do I get the GUIDs?
          >>[/color]
          >
          > Menu:
          > Tools->Create GUID
          >
          > ... and also .. each class you want to expose must have constructor with
          > no parameters ....
          >
          > Regards,
          > Josip Habjan
          > URL: http://www.habjansoftware.com
          >[/color]


          Comment

          • Josip Habjan

            #6
            Re: VB 6 Com Interop question

            Describe problem with .net part ?

            Regards,
            Josip Habjan
            URL: http://www.habjansoftware.com



            "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
            news:%23AaR0XBe FHA.1448@TK2MSF TNGP09.phx.gbl. ..[color=blue]
            > It works!! Now if I can just get the .Net part working correctly I'll be
            > flying!
            > Thanx!
            >
            > "Josip Habjan" <jhabjan@spamof f-net.hr> wrote in message
            > news:d9cl1i$ru1 $1@magcargo.vod atel.hr...[color=green]
            >> "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
            >> news:e4n5N$2dFH A.3032@TK2MSFTN GP10.phx.gbl...[color=darkred]
            >>>
            >>> How do I get the GUIDs?
            >>>[/color]
            >>
            >> Menu:
            >> Tools->Create GUID
            >>
            >> ... and also .. each class you want to expose must have constructor with
            >> no parameters ....
            >>
            >> Regards,
            >> Josip Habjan
            >> URL: http://www.habjansoftware.com
            >>[/color]
            >
            >[/color]


            Comment

            • Bryan Dickerson

              #7
              Re: VB 6 Com Interop question

              That's in another thread...

              "Josip Habjan" <jhabjan@spamof f-net.hr> wrote in message
              news:d9evvs$lpu $1@magcargo.vod atel.hr...[color=blue]
              > Describe problem with .net part ?
              >
              > Regards,
              > Josip Habjan
              > URL: http://www.habjansoftware.com
              >
              >
              >
              > "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
              > news:%23AaR0XBe FHA.1448@TK2MSF TNGP09.phx.gbl. ..[color=green]
              >> It works!! Now if I can just get the .Net part working correctly I'll be
              >> flying!
              >> Thanx!
              >>
              >> "Josip Habjan" <jhabjan@spamof f-net.hr> wrote in message
              >> news:d9cl1i$ru1 $1@magcargo.vod atel.hr...[color=darkred]
              >>> "Bryan Dickerson" <txprphan@netsc ape.net> wrote in message
              >>> news:e4n5N$2dFH A.3032@TK2MSFTN GP10.phx.gbl...
              >>>>
              >>>> How do I get the GUIDs?
              >>>>
              >>>
              >>> Menu:
              >>> Tools->Create GUID
              >>>
              >>> ... and also .. each class you want to expose must have constructor with
              >>> no parameters ....
              >>>
              >>> Regards,
              >>> Josip Habjan
              >>> URL: http://www.habjansoftware.com
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              Working...