0

I have a managed DLL that I want to use in a legacy application I'm modifying, so far the steps I have taken are.. pretty much following this guide to a T: How to call a managed DLL from native Visual C++ code in Visual Studio.NET or in Visual Studio 2005

So, I created a strong name for the DLL, generated the .tlb file, #import it into my C++ code, notice that, oh cool, the intellisense can even see the classes (and pointers to classes) when I'm calling it, but after compiling it I recieve this linker error:

Test.tlb : fatal error LNK1136:  invalid or corrupt file.

It may be my C++ project is set up wrong, originally I recieved the "fatal error LNK1181: Cannot open input file 'Test.tlb' " until I moved it to the directory containing my solution/project.

Does anyone know what might be causing this?

2
  • VC++ 6 is from 1998, the first .NET release was done in 2002. I'm not sure it can be done...
    – user786653
    Aug 13, 2011 at 19:05
  • TLB is COM, though, and that's both language-neutral and predating VC6. You can write .Net COM code today that will work with code compiled in 1996 !
    – MSalters
    Aug 16, 2011 at 14:58

1 Answer 1

1

Yes, your project setup is wrong. You seem to have added the .tlb file to the linker's Additional Dependencies setting. That's not correct, it doesn't contain any linkable code. It only contains declarations in a format that only the #import directive can understand.

Remove test.tlb from the linker settings.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.