我正在尝试调用需要Asciiz指针的DLL函数:
int doExample(Asciiz* FolderPath, Asciiz* OutputPath, int Flags);
我已尝试使用StringBuilder
,但我一直收到有关访问受保护内存的错误。这是我的C#代码:
public class Example
{
[DllImport("Example.dll", EntryPoint="?doExample@Example@@QADHPYDH0P6A_N0ZZ000@Z")]
static extern int doExample(StringBuilder folderPath, StringBuilder outputPath, int flags);
public int do(string folderPath, string outputPath)
{
StringBuilder FolderPath = new StringBuilder(folderPath);
StringBuilder OutputPath = new StringBuilder(outputPath);
doExample(FolderPath, OutputPath, 0);
}
}
关于为什么会发生这种情况的任何想法?或者这严格来说是C ++代码中的错误?
编辑:根据评论,这里有更多信息: