解决方式:将托管 System.String 中的内容复制到非托管内存(Marshal.StringToHGlobalAnsi)
class HttpsSend {
[DllImport("httpsSend.dll")]
public static extern IntPtr markInvoice(IntPtr url, IntPtr input);
public static string Send(string url, string content)
{
IntPtr urlPtr = Marshal.StringToHGlobalAnsi(url);
IntPtr contentPtr = Marshal.StringToHGlobalAnsi(content);
IntPtr outPutIntPtr = markInvoice(urlPtr, contentPtr);
string outPut = Marshal.PtrToStringAnsi(outPutIntPtr);
return outPut;
}
}