adv12
adv12

Reputation: 8551

Types from COM DLL not available to my VC++ code after '#import "MyDll.dll"'

I'm a COM newbie trying to make a dirt-simple C++ console app to test consuming a COM DLL. In my lone .cpp file, I include the line

#import "AgLeaderFile.dll"

to import the COM DLL of interest. I added the DLL's directory to "Executable Directories" in Project Properties->Configuration Properties->VC++ Directories. I know it is being found, because the red squiggles under the #import directive disappeared when I added this path, and a .tlh file is getting generated in the project's output directory when I build.

Unfortunately, when I refer to types declared in the .tlh file, I get "undeclared identifier" errors (C2065). It seems like the compiler isn't finding the .tlh file.

undeclared identifier squiggles

What is the correct way to make the types from the generated .tlh file available to my .cpp file? I thought the #import statement was supposed to be enough. Do I need to add $(TargetDir) as an additional include directory or something? (That sounds hacky.)

Upvotes: 0

Views: 54

Answers (1)

adv12
adv12

Reputation: 8551

The types I was trying to reference were in a namespace. Adding a using namespace AgLeaderFileLib fixed my problem.

Upvotes: 1

Related Questions