[Mono-devel-list] Problem with P/Invoke
jonpryor at vt.edu
Sun Feb 1 11:58:02 EST 2004
On Sun, 2004-02-01 at 10:07, Martin Baulig wrote:
> On Sat, 2004-01-31 at 23:27, Jonathan Pryor wrote:
> > Thus, your DllImport should be:
> > [DllImport ("libc.so")]
> > private static extern IntPtr strncpy (StringBuilder dest,
> > string src, uint len);
> > Now, the bad news begins. When I try this under Mono 0.29, the code
> > doesn't work correctly. Nothing appears to be copied.
> You forgot a more serious issue:
> The first argument or strncpy is a `char *' and you can't just overwrite
> the managed `StringBuilder' instance.
The runtime is supposed to handle this transparently, so that
StringBuilder can be used with fixed-with buffers.
See (beware line wraps):
More information about the Mono-devel-list