I am trying to include a C ++ library (DLL) in my C # project, but every time I do this, I get the following error message in VS2012
A reference to 'C:\Users\HiepDang\Desktop\mydll.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
When I try to add Com + Component, I get the following error message in the window
One or more files do not contain a library of components or types. These files cannot be installed.
Error 80110425 has occurred.
An unknown error has occurred. You must check all the documentation for the solution. If additional information is not available, contact technical support.
I follow the flow here and here , but my problem is not resolved.
In C ++, I can use dll like:
extern "C" __declspec( dllimport ) int mymethod(const char *key, char *data, size_t buflen);
const char* key = "test";
char* data = new char[1024];
int buflen = 1024;
int result = mymethod(key,data, buflen);
In C #, I use dll like:
[DllImport("mydll.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern int mymethod([MarshalAs(UnmanagedType.LPTStr)]string key, [MarshalAs(UnmanagedType.LPTStr)]string data, uint buflen);
private static int testdll()
{
string key = "123456789";
string buf = string.Empty;
mymethod(key, buf, 1024);
return 0;
}
Can you tell me about any solutions to solve it.
P.s: . , -
: dll. "", 8-13 , mymethod "buf". "buf".