Problem with .NET Array and TlbExp (10/12)

Discussion in 'Microsoft Dot NET' started by tcarvin, Oct 12, 2004.

  1. tcarvin

    tcarvin Guest

    I'm having a problem exposing a method from .NET to COM (specifically VB).

    I had a pre-existing .NET Assembly that I needed to expose to COM. So
    I created an explicit interface for the classes and methods I wanted to
    expose, and then had my existing .NET classes implement them (pretty much
    I let VS.NET stub out my "implements" routines and then forwarded the calls
    to my existing routines). I used ClassInterface(ClassInterfaceType.None)
    on my classes to force the use of the interfaces.

    Now here's the problem. While my simple read-only propertys seem to work,
    I tried calling a method that takes in an array of objects and the VB6
    environment balked with an "unsupported type" error at compile time (plus
    that method's signiture had no "intellisense").

    Here's the interface method:

    <DispIdAttribute(1)> _
    Function CreateFile(ByVal DbfDir As String, _
    ByVal DbfTitle As String, _
    ByVal FieldDefs() As IFieldDefinition) _
    As IFile

    Here's the TypeLib info:

    [id(0x00000001)]
    HRESULT CreateFile(
    [in] BSTR DbfDir,
    [in] BSTR DbfTitle,
    [in] SAFEARRAY(IFieldDefinition*) FieldDefs,
    [out, retval] IFile** pRetVal);

    I can't see the problem. Any help is appreciated!
    Tom

    PS - I posted this in the Interop forum before, but it seems pretty quite
    there. I apologize for the semi-cross-posting.
     
    tcarvin, Oct 12, 2004
    #1
    1. Advertisements

  2. tcarvin

    tcarvin Guest

    Got past that one too. The array needed to be passed ByRef not ByVal...

    (tcarvin) wrote in message news:<>...
    > I'm having a problem exposing a method from .NET to COM (specifically VB).
    >
    > I had a pre-existing .NET Assembly that I needed to expose to COM. So
    > I created an explicit interface for the classes and methods I wanted to
    > expose, and then had my existing .NET classes implement them (pretty much
    > I let VS.NET stub out my "implements" routines and then forwarded the calls
    > to my existing routines). I used ClassInterface(ClassInterfaceType.None)
    > on my classes to force the use of the interfaces.
    >
    > Now here's the problem. While my simple read-only propertys seem to work,
    > I tried calling a method that takes in an array of objects and the VB6
    > environment balked with an "unsupported type" error at compile time (plus
    > that method's signiture had no "intellisense").
    >
    > Here's the interface method:
    >
    > <DispIdAttribute(1)> _
    > Function CreateFile(ByVal DbfDir As String, _
    > ByVal DbfTitle As String, _
    > ByVal FieldDefs() As IFieldDefinition) _
    > As IFile
    >
    > Here's the TypeLib info:
    >
    > [id(0x00000001)]
    > HRESULT CreateFile(
    > [in] BSTR DbfDir,
    > [in] BSTR DbfTitle,
    > [in] SAFEARRAY(IFieldDefinition*) FieldDefs,
    > [out, retval] IFile** pRetVal);
    >
    > I can't see the problem. Any help is appreciated!
    > Tom
    >
    > PS - I posted this in the Interop forum before, but it seems pretty quite
    > there. I apologize for the semi-cross-posting.
     
    tcarvin, Oct 13, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TDH
    Replies:
    2
    Views:
    272
    TrongAn Hoang
    Nov 23, 2003
  2. Guest
    Replies:
    1
    Views:
    178
    [MSFT]
    Apr 15, 2004
  3. Andrew Boothman

    VB.NET, VC.NET & C#.NET and the .NET framework

    Andrew Boothman, Jul 23, 2004, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    271
    David Williams , VB.NET MVP
    Jul 23, 2004
  4. Guest

    Question with tlbExp

    Guest, Dec 8, 2004, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    166
    Guest
    Dec 8, 2004
  5. elziko
    Replies:
    4
    Views:
    322
    elziko
    Jun 27, 2005
Loading...

Share This Page