我認爲這個問題是我的C++函數裏面,但我想在C++ DLL這個在C#中的std :: string?
C++函數:
bool __declspec(dllexport) OpenA(std::string file)
{
return true;
}
C#代碼:
[DllImport("pk2.dll")]
public static extern bool OpenA(string path);
if (OpenA(@"E:\asdasd\"))
我得到一個異常的記憶是腐敗的,爲什麼?
如果我刪除std :: string參數,它的效果很好,但與std :: string它不起作用。
也許你可以解決它通過一個託管的C++橋解開字符串? [這裏](http://stackoverflow.com/questions/267057/creating-a-mixed-mode-c-bridge-from-c-to-c)是關於這個問題的SO問題。 – FeatureCreep 2009-05-17 13:11:58