调用C++动态链接库出现错误

解决方式:将托管 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;
}
}
上一篇:Unable to locate package python-pip


下一篇:PHPCMS-首页的二级导航、轮播效果