I want to send a string from unmanaged C-code to managed VB .Net that runs at a Raspberry pi running Linux and mono. I debug the Dynamic C library (.so) in netbeans by calling the dynamic C library from c++. This works like a charm, but when I call the same function from VB .Net running in Linux with Mono it returns a empty string.
Here's the code
C
void HelloCstr(/*OUT*/ char* hello)
{
string s = ("Hello World");
strcpy(hello, s.c_str());
}
_
C++
std::string ss;
HelloCstr((char*)ss.c_str()); // ss is filled with "Hello World"
_
VB .Net
<DllImport("libDllTest", CharSet:=CharSet.Ansi)>
Public Shared Sub HelloCstr(str As System.Text.StringBuilder)
End Sub
Public Shared Function HelloWorld() As String
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder(200)
HelloCstr(sb) //After this call sb.Length == 0
Return sb.ToString() // this returns an empty string
End Function
What am I doing wrong??