Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have a problem in time to Call DLL which writed in C.
this property of Method:
short PerformCommandTCP( char *ipAddress, int tcpPortNumber, char *inXML, char *outXML )

the Last Parameter must be passing BYREF

my Code is:

[DllImport("AshraitPCI.dll")]
public static extern short PerformCommandTCP(string sIpAddress, int iTcpPortNumber, string sInXML, StringBuilder sOutXML);

after first time i get Error:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

please, tell me what is a problem!
thanks
Posted

1 solution

You cannot pass managed strings to a C/C++ library, you must marshall the data to unmanaged arrays. See http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx[^] for details.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900