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?
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.