Pass string from vb.net 2005 to c dll

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.
 
M

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.

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
 
H

Herfried K. Wagner [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top