[prev in list] [next in list] [prev in thread] [next in thread]
List: mono-devel-list
Subject: Re: [Mono-devel-list] P/Invoke question
From: Marcus <mathpup () mylinuxisp ! com>
Date: 2004-08-22 23:18:46
Message-ID: 200408221818.46532.mathpup () mylinuxisp ! com
[Download RAW message or body]
No, Mono does not appear to marshal the data correctly when passing a
reference to an array of strings. The C# signature should be
private static extern int f(ref string[] data);
if the C++ function is
int f(char ***data);
I did not realize that Mono didn't support this properly until you mentioned
it because I was testing on Linux using Rotor (MS's "shared source" version
of .NET).
If you recall, I mentioned in a previous email that the CLI spec only
addresses a limit set of data types that must be marshaled, and "ref
string[]" is not one of them. Integer and floating point types, enums,
strings, and pointers to them are required to be supported in both directions
(managed -> unmanaged and unmanaged -> managed). Arrays and delegates are
required to be supported in managed -> unmanaged, but not required to be
suppoted from unmanaged -> managed. Obviously .NET goes beyond these
requirements, but Mono does not implement this particular case.
Although it isn't a bug per se, the Mono developers should probably be
informed about this. You could file a bug report about this. Or I can if you
would prefer.
Marcus
> Marcus:
> Thanks for the code snippets. However, I could not get them to work
> properly. data.cpp compiles and runs fine standalone, and compiles fine
> as a shared lib, however, whenever data.cs calls it, garbage is
> returned. Maybe I'm doing something silly.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic