Pass string from vb.net 2005 to c dll

  • Thread starter Thread starter Bob Simoneau
  • Start date Start date
B

Bob Simoneau

I have a function call to a C DLL which takes a string as a parameter, and
modified the string. I keep getting the following error. I beleive I have
to marshal the string, but I am unsure how to do that.

Error;
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
 
Bob Simoneau said:
I have a function call to a C DLL which takes a string as a parameter, and
modified the string. I keep getting the following error. I beleive I have
to marshal the string, but I am unsure how to do that.

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

Instead of passing a string, try passing a StringBuilder (and defining the
function to pass a StringBuilder as well).

HTH,
Mythran
 
Bob Simoneau said:
I have a function call to a C DLL which takes a string as a parameter, and
modified the string. I keep getting the following error. I beleive I have
to marshal the string, but I am unsure how to do that.

I suggest to post the function prototype in C and the 'Declare' or
'DllImport' you are using in VB.NET.
 
Back
Top