Using Interface type from the imported TLB (Attributed COM)
-
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
-
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
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
-
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
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