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. ATL / WTL / STL
  4. Using Interface type from the imported TLB (Attributed COM)

Using Interface type from the imported TLB (Attributed COM)

Scheduled Pinned Locked Moved ATL / WTL / STL
csharpcomc++visual-studiohelp
3 Posts 3 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.
  • A Offline
    A Offline
    arun1405
    wrote on last edited by
    #1

    I am writing a attributed COM component in Visual Studio .NET 2003 (VC++ 7.1). For reusing the types defined in some other TLB, I want to import this TLB that I do by inserting the following line in stdafx.h. [ importlib("test.tlb") ]; This 'importlib' attribute places this line in the library block of the IDL file. However, now if some of the interface methods in my COM component want to return an interface defined in test.tlb, it gives me IDL compilation error. Perhaps, it is probably since the automatic IDL generation by the compiler puts all the interface declarations of my component outside the library block, and the importlib attribute generates the importlib line inside the library block... and, so the interface declarations of my component are not able to recognize the interface types defined in the imported type library. Can anyone suggest me if I am importing the library in a wrong way, or if there is any other solution to it ? Thanks & Regards, Arun

    M W 2 Replies Last reply
    0
    • A arun1405

      I am writing a attributed COM component in Visual Studio .NET 2003 (VC++ 7.1). For reusing the types defined in some other TLB, I want to import this TLB that I do by inserting the following line in stdafx.h. [ importlib("test.tlb") ]; This 'importlib' attribute places this line in the library block of the IDL file. However, now if some of the interface methods in my COM component want to return an interface defined in test.tlb, it gives me IDL compilation error. Perhaps, it is probably since the automatic IDL generation by the compiler puts all the interface declarations of my component outside the library block, and the importlib attribute generates the importlib line inside the library block... and, so the interface declarations of my component are not able to recognize the interface types defined in the imported type library. Can anyone suggest me if I am importing the library in a wrong way, or if there is any other solution to it ? Thanks & Regards, Arun

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      This isn't meant to be snarky, but don't use attributed ATL. It's more headache than it's worth. Go with regular ATL and use #import to generate wrappers for the stuff in the TLB file.

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

      1 Reply Last reply
      0
      • A arun1405

        I am writing a attributed COM component in Visual Studio .NET 2003 (VC++ 7.1). For reusing the types defined in some other TLB, I want to import this TLB that I do by inserting the following line in stdafx.h. [ importlib("test.tlb") ]; This 'importlib' attribute places this line in the library block of the IDL file. However, now if some of the interface methods in my COM component want to return an interface defined in test.tlb, it gives me IDL compilation error. Perhaps, it is probably since the automatic IDL generation by the compiler puts all the interface declarations of my component outside the library block, and the importlib attribute generates the importlib line inside the library block... and, so the interface declarations of my component are not able to recognize the interface types defined in the imported type library. Can anyone suggest me if I am importing the library in a wrong way, or if there is any other solution to it ? Thanks & Regards, Arun

        W Offline
        W Offline
        wangweixing2008
        wrote on last edited by
        #3

        Please insert "[ importlib("test.tlb") ];" in current .idl file. eg: [ uuid(95E822B6-6B10-4e86-9603-6CECB6135867), version(1.0), helpstring("xxxxx 1.0 Type Library") ] library xxxxxLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); importlib("test.tlb"); //here insert! ... } good luck!

        i love vc!This will appear at the end of messages you post to the Code Project

        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