我试图通过dll多次调用C ++项目的同一功能到C#项目,但是C#项目的执行在第一次调用该函数后不久就终止了,甚至没有执行下一条立即语句。
C ++代码:
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap- select@1.13.9/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
</head>
<select name="stations" id="stations">
<option>Station 1</option>
<option>Station 2</option>
<option>Station 3</option>
</select>
<script>
$(document).ready(function(){
$("#stations").selectpicker();
});
</script>
C#代码:
extern "C" __declspec(dllexport) char* rev(const char* str)
{
xxxx
xxxx
}
我希望每次在C#文件中调用C ++ [DllImport("Tessaract.dll", SetLastError = true)]
public static extern string rev([MarshalAs(UnmanagedType.LPStr)] string a);
string x = rev("abcxyz");
string y = rev("xyzabc");
函数