I built a C# application with WPF on Visual Studio 2012 that uses C++ DLL and targets .NET4.5. I have two projects running, one for the C# project and the other for C++ DLL project. I released both projects into a folder that has a .exe
for C# and a .dll
for C++ in the same folder.
I run them on my machine where they were developed and everything works fine. I run the .exe
in other machines and it throws this exception:
System.DllNotFoundException: Unable to load DLL
It's not recognizing the DLL that is in the same folder.
I tried many things and nothing seems to work. I followed the solution in this post but nothing worked.
The Dev and Target machine are identical. In Dev, Visual Studio 2012 is installed, but that's the only difference.
Code:
C#:
[DllImport(@"Wireless.dll", EntryPoint = "?cert_exists@certificate@CertFuncs@@SAHHPBD@Z", CallingConvention = CallingConvention.Cdecl)]
static extern int cert_exists(int store, [MarshalAs(UnmanagedType.LPTStr)]string cert_str);
C++:
static int __declspec(dllexport) cert_exists(int type, LPCSTR cert_str);
Update:
If I install Visual Studio 2012 on the target machine, everything works fine. If I remove it, the application crashes again. Any ideas on what VS is adding that can make the application work?