Having in C++:
extern "C" MY_API int connect(const char* pcHost,const int nPort, ConnectionId_T *pConId);
Being:
pcHost
an IPnPort
a portpConId
a constant (-1)
My try is:
[DllImport("my.dll", CharSet = CharSet.Ansi)]
public static extern int connect(StringBuilder pcHost, int nPort, ConnectionId_T pConId);
But when I try to connect:
StringBuilder ip = new System.Text.StringBuilder();
ip.Append("1.1.1.1");
int nPort = 1111;
ConnectionId_T nConId = MY_NCONID // This is defined previously as -1 (public const int MY_NCONID = -1)
connect(ip, nPort, nConId))
I get an AccesViolationException on the connect
line. Do I've my marshal wrong?
PS: ConectionId_T
is defined as using ConnectionId_T = System.Int32;
Thanks in advance.