Thanks Mark
I looked up ComClass and got it working

-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of Mark Hurd
Sent: Sunday, 13 June 2010 11:59 AM
To: ozDotNet
Subject: Re: upgrading a VB6 Class to Dot Net, then exposing it back to VB6
via Com Interop - there has to be an easier way

I don't have all the details in front of me, but VB.NET provides the
interface behind the scenes if you add the relevant attributes. You
can use one attribute (ComClass I think) that does all the work, or a
combination that allows more settings.

Copying from my current code: (The ComVisible attribute is instead of
making the whole assembly visible to COM which FxCop dislikes.)

    <ComVisible(True)> _
    <ProgId("Alternate.ProgId")> _
    <Guid(SomeClass.ClassId)> _
    Public NotInheritable Class SomeClass

        ''' <summary>
        '''   An explicit GUID to be used for this class's CLSID.
        ''' </summary>
        ''' <remarks></remarks>
        <ComVisible(False)> _
        Public Const ClassId As String =
"1234d5c8-83e2-484b-b7dd-f87e2e4567e3"
        'Public Const InterfaceId As String =
"56789b7d-8677-4dc5-8682-8421a8901c77"
        'Public Const EventsId As String =
"123fab6a-b957-4c73-9f0f-f06794c21d23"

As implied by the comments you can specify the InterfaceId and
EventsId as well if needed, especially using ComClass.

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)


On Sun, Jun 13, 2010 at 12:10 AM, Kirsten Greed <[email protected]>
wrote:
> Hi All
>
> Am I missing some magic trick?  There seems to be a lot of typing involved
> in the following upgrade
>
> In VB6 I have
>
> Class Customer
>
>             Public CustomerID as long
>
>             Public CustomerName as string
>
>             ‘ and lots of other properties
>
> End class
>
>
> Once this is upgraded, it seems that to get this to work I have to
implement
> an interface
>
> Public Interface _Customer
>
>             Property CustomerID as long
>
>             Property CustomerName as string
>
>             ‘ and lots of other properties
>
> End interface
>
> Yet the upgrade wizard does not create the interface for me,  I think it
> should both create the interface and hook up the properties
>
> Is there a way of doing this?
>
> Thanks
>
> Kirsten

Reply via email to