Well here's a summary of what I've tried and what it's doing now:
To review, I have a third party DLL compiled to machine language (DLL A), and I used that inside a C++ project to make my own DLL which builds onto it (DLL B), and compiled it and put it into a C# project. I import it using the interop service and my syntax is good and everything compiles correctly, but when I try to call a function in it, I was getting a DllNotFoundException.
That's where I was at my previous post. Since then:
- I've put DLL B into each of the possible folders where it could be accessed (the solution, project, debug and release folders) to make sure it's finding it.
- I also recompiled DLL B in release mode instead of debug, and re-copied it into those folders.
- I also included DLL A into those folders and imported it into the project.
At least one of those things must have partially fixed it, because I no longer get a DllNotFoundException when I call the function; instead I get BadImageFormatException, and it says "An attempt was made to load a program with an incorrect format." and it says "HRESULT: 0x8007000B".
As an alternative, I also tried to just include DLL A instead of DLL B, with the intention of recreating DLL B within C# by using DLL A directly. I include and reference DLL A and its functions the same way I was doing with DLL B, but I just get a DllNotFoundException.
I don't really care which way works, because DLL B is simple and I can recreate it (it might even be cleaner that way) but whatever way works is fine with me.
Does anyone know what I'm doing wrong?