Long story short: I've been able to load a C# dll in C++ by having the
C# project generating a type library (tlb) and #importing that in C+
+. The #import directive looks like a compiler shortcut that
generates a tlh and tli locally. Now what I want to be able to do is
generate the tlh and tli somehow and include them directly in my C++
project, thus doing away with the need for the #import statement.
I've looked at the MIDL.exe help but couldn't see a way to do this. I
also tried using a new C++ project that simply #imports the tlb with
the hope that I could specify where the tlh and tli get generated, but
I couldn't see a setting for that.
Any help would be appreciated.
Cheers
Adam Bryant
Carl Daniel [VC++ MVP] - 26 Oct 2007 15:28 GMT
> Long story short: I've been able to load a C# dll in C++ by having the
> C# project generating a type library (tlb) and #importing that in C+
[quoted text clipped - 7 lines]
> the hope that I could specify where the tlh and tli get generated, but
> I couldn't see a setting for that.
You've pretty much summed up the situation: #import is a compiler tool that
builds a .tlh/.tli from a .tlb and there's no way to specify where the
resulting files should be placed. The best you can do is to create a simple
C++ project that #imports your .tlb and then copy the .tlh/.tli from the
"intermediate files" directory of the project (typically %PROJECTDIR%\Debug
or %PROJECTDIR%\Release) to a common include directory.
-cd