I'm trying to import my C++ Dll in C#. It seems to work fine for functions without parameters but i'm having issues with my function which has some.
My C++ function :
__declspec(dllexport) bool SetValue(const std::string& strV, bool bUpload)
{
return ::MyClass::SetValue(strV.c_str(), bUpload);
}
It is wrapped in "extern "C" {"
The function calls another function which is :
bool SetValue(const char* szValue, bool bUpload)
{
}
My C# Function :
[DllImport("MyDll.dll", EntryPoint = "SetValue", CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetValue([MarshalAs(UnmanagedType.LPStr)]string strVal, bool bUpload);
When I use the debug mode and enter in SetValue(const char* sZvalue, bool bUpload) function, the sZvalue is "0x4552494F" but when I try to expand Visual Studio 's view to see the value it says "undefined value".
Maybe somebody has an idea of what's wrong with my code ?
Thanks !