I created a C # application with WPF in Visual Studio 2012 that uses the C ++ DLL and the target .NET4.5. I have two projects, one for a C # project, and the other for a C ++ DLL project. I released both projects in a folder with .exefor C # and .dllfor C ++ in the same folder.
I run them on my machine, where they were developed, and everything works fine. I run .exeon other machines and throw this exception:
System.DllNotFoundException: Unable to load DLL
Does not recognize a DLL located in the same folder.
I tried a lot of things and nothing works. I executed the solution in this post , but nothing worked.
The Dev and Target machine are identical. Visual Studio 2012 is installed in Dev, but this is the only difference.
the code:
WITH#:
[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 will be fine. If I remove it, the application crashes again. Any ideas on adding VS that might make the application work?
source
share