none
COM Interop: importing module type from .tlb HOWTO RRS feed

  • Question

  • Hi everyone,

      I'm attempting to create an Interop assembly of a tlb where are defined only module functions.

     

     

    When I invoke the tlbimp I get the following result

    Code Snippet

    C:\TEMP\gtdAPI\API>tlbimp gtd_api.tlb /namespace:GtvApi /out:gtvapiinterop.dll /verbose
    Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42
    Copyright (C) Microsoft Corporation.  All rights reserved.

    Resolved referenced file 'gtd_api.tlb' to file 'C:\TEMP\gtdAPI\API\gtd_api.tlb'.
    Type 'GraphTalkDev' imported.
    Type library imported to C:\TEMP\gtdAPI\API\gtvapiinterop.dll

     

     

    It states that the type GraphTalkDev has been imported. That type is a module.

    When I reference the assempbly it's pratically empty.

     

    There's a way to import it (I imagine creating a static class that exposes the methods)? (I would avoid to implement a COM wrapper class)

     

    Here follows the tlb declarations

    Code Snippet

    // Generated .IDL file (by the OLE/COM Object Viewer)
    //
    // typelib filename:

    [
      uuid(CBD18420-51F8-11D1-9602-444553540000),
      version(0.0),
      helpstring("GraphTalk Developer API Type Library")
    ]
    library GraphTalkDevAPI
    {
        // TLib :     // Forward declare all types defined in this typelib

        [
          dllname("gtvapi.dll"),
          helpstring("GraphTalk Developer API Calls")
        ]
        module GraphTalkDev {
            [entry(0x60000000), helpstring("Sign on to and initialize GraphTalk Developer")]
            int _stdcall GTD_initialize(
                            [in] LPSTR command_line,
                            [in] LPSTR user_id,
                            [in] LPSTR password);
            [entry(0x60000001), helpstring("Sign off from and terminate GraphTalk Developer")]
            int _stdcall GTD_done();
            [entry(0x60000002), helpstring("Convert an object identifier string into an object handle")]
            int _stdcall GTD_new_object(
                            [out] long* object_handle,
                            [in] LPSTR object_id);
            [entry(0x60000003), helpstring("Obtain the object identifier string from an object handle")]
            int _stdcall GTD_object_id(
                            [in] long object_handle,
                            [out] LPSTR* object_id);
            [entry(0x60000004), helpstring("Set a GraphTalk object's attribute to an integer value")]
            int _stdcall GTD_set_attr_integer(
                            [in] long object_handle,
                            [in] long link_handle,
                            [in] LPSTR attrinute_name,
                            [in] long te_date,
                            [in] long la_date,
                            [in] int value);
           

    // ....................... REMOVED ................

     

    [entry(0x6000005a), helpstring("Set the codepage for the API function string arguments")]
            int _stdcall GTD_translate_strings([in] LPSTR codepage_name);
        };
    };

     

     


    Thursday, February 28, 2008 10:34 AM

Answers

  • TlbImp doesn't support modules. You have to manually write the corresponding DllImport methods.

     

     

    Thursday, February 28, 2008 1:23 PM
    Moderator