c ++ c dll # call in inbound and outbound parameters on char *

c ++ dll interfaces of prototype: int CheckSN (const char * InfoList, char * msg);

c # calls into:

[DllImport("sncplusInterface.dll", EntryPoint = "CheckSN", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CheckSN(string InfoList, StringBuilder msg);

Call is:

StringBuilder chOutMsg = new StringBuilder(1024);

CheckSN(chData, chOutMsg/*ref chOutMsg*/);

string str = chOutMsg.ToString();

With the ref or out keyword crash

 

Guess you like

Origin www.cnblogs.com/bigfi/p/12521958.html