-1
我们希望将字符串从csharp程序传递给vC++。如何通过csharp程序将字符串传递给vC++ dll
以下是代码: 在C#
[DllImport("ConsoleApplication2.dll")]
public static extern int main_c(StringBuilder IpAddr, int p);
public string[] tcp()
{
StringBuilder buffer = new StringBuilder("192.168.1.100");
int i = main_c(buffer, 34318);
在VC
extern __declspec(dllexport) int main_c(char *peer,int port)
{
这给出了一个错误为 “:main_c”具有不平衡堆栈”如何才能做到这一点 ?
C#代码运行正常吗?我的意思是,如果从.net应用程序运行它,它将运行而不会产生任何错误? –
[将C#字符串传递给C++并将C++结果(字符串,字符\ * ..无论)传递给C#]的可能重复(http://stackoverflow.com/questions/2179270/pass-c-sharp-string-to- c-and-pass -c-result-string-char-whatever-to-cs) – stijn
我试过上面的链接它不起作用。即该解决方案不起作用 –