1

I've compiled a C++ DLL Library using MinGW, which I want to use in my C# Project. Initially, I was developing on my desktop, where everything worked - I got no missing DLL Exceptions, and I could use the functions needed in my C# Code.

However, after moving the project to my Laptop, which has the same version of Windows, Visual Studio and MinGW, I can't get it to work. I made sure the DLL is in the correct folder and has the "Copy Always" option, I recompiled it, and checked it's dependencies with Dependency Walker, but I can't get it to work. The DLL is obviously there, File.Exists("myLib.dll") always returns true, and even adding the full path to it doesn't fix it.

The only thing that I think could be wrong is these two erros that Dependency Walker returns, but I've read that that's an error withing the DW.

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.

Does anyone know what could be causing this? It's bothering me, because it works on one PC and not the other, but I need it to work on any Windows PC.

Stil
  • 19
  • 1
  • I've run into similar issues in the past. Have you tried registering the DLL? http://stackoverflow.com/questions/4897685/how-do-i-register-a-dll-file-on-windows-7-64-bit. Is statically linking the DLL into the executable an option? – chiaboy Mar 28 '15 at 13:10
  • It says that DllRegisterServer entry point was not found. I don't understand why it won't work, if it works just fine on my other PC. – Stil Mar 28 '15 at 13:22
  • Is your. Net framework version still same, in both the old and new pc – Saravanan Mar 28 '15 at 13:24
  • DW just isn't very good at showing you what is the problem, it has not been maintained in a long time and shows too much irrelevant noise. Surely the real problem is that you forgot to copy a dependent DLL, one that exists on your dev machine but not your laptop. Use SysInternals' Process Monitor, you'll see the program searching for the DLL and not finding it. – Hans Passant Mar 28 '15 at 13:27
  • @saravanan, yes, both computers have the same .NET version installed. @HansPassant, I ran Process Monitor on it. All I could find is `mscorrc.dll` with `PATH NOT FOUND` or `NAME NOT FOUND`, and some .resource extensions not being found. I can't see any operations for opening/reading myLib.dll though, only CreateFile, QueryInformation, CreateMapping and CloseFile. – Stil Mar 28 '15 at 13:56
  • Is ther a missing DLL Exceptions? Look at the details of this exception. – DrKoch Mar 28 '15 at 14:18
  • @DrKoch oh thank you! EDIT: Nevermind, after fixing the BadImageFormatException, it goes back to DLLNotFoundException. – Stil Mar 28 '15 at 15:14
  • "Does not work" is not a proper description. What errors do you get? Does it simply not compile at all? Does your computer explode into a glorious fireball when you hit build? Give us something so we can at least guess. – Krythic Mar 28 '15 at 15:42
  • It compiles, but when I try to call the functions in the DLL I get a "DLLNotFoundException", however, the DLL is definitely there, because a) it works on my other PC and b) File.Exists returns true. – Stil Mar 28 '15 at 15:55
  • Also, running the .exe file, that was compiled on my desktop PC and uses the same .dll file works just fine, but if I re-compile the exact same code with all the same files, it throws the DLLNotFoundException. – Stil Mar 28 '15 at 16:18

0 Answers0