We want to have a csharp wrapper for an exisiting dll and now trying to write a wrapper for the dll to wrap it in csharp.
c++ code:
extern "C" __declspec(dllexport) int test(unsigned char* initValue)
{
//// Get a handle to the DLL module.
HINSTANCE hinstLib = LoadLibrary(TEXT("test.dll"));
return 0;
}
The C# wrapper:
public class TestWrapper
{
[DllImport("cppWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int test(byte[] outInitValue);
}
But go this exception:
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
"Test.dll" is a WIN32 (x86) DLL but we changed the build type to x86 but that didn´t work. Without LoadLibrary(TEXT("test.dll"));
everything works fine.
Aucun commentaire:
Enregistrer un commentaire