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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With