Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing a lib file using visual studio

I am trying to import a file as below:

#import "francais.dll"

It says to me that it cannot open source file "C:/xxxx/Proj/Release/francais.tlh"

The Library file is existing in Proj.

How to solve that?

like image 510
MelMed Avatar asked Oct 15 '13 14:10

MelMed


1 Answers

It is not a "library file", it is a COM server. The #import directive auto-generates a .tli and a .tlh file from the type library that's embedded in francais.dll. There's no obvious reason why it wouldn't be able to load that .tlh file, there's probably something wrong with that DLL. Hard to see from here. Do make sure that you are not ignoring earlier errors, start at the top of the Error List window.

As a basic check, you can look at that type library yourself. Run OleView.exe from the Visual Studio Command Prompt and use File + View Typelib, select that DLL. You need to see the content of the type library, decompiled into IDL.

You can also see it in VS itself, use File + Open + File and select the DLL. You'll see the resources that are embedded in the DLL, there needs to be a node labeled "TYPELIB" with one resource with ID 1 that's the actual type library. If anything goes wrong with these two verifications then the #import directive isn't likely to work either.

And do note that it is odd that it tries to find the file in the Release directory. You'd normally always start with the Debug configuration.

like image 83
Hans Passant Avatar answered Sep 27 '22 21:09

Hans Passant