[Mono-devel-list] How to marshal &argv for p/invoke?

Peter Williams peter at newton.cx
Sun Nov 16 00:28:08 EST 2003

Hi all,

	I'm trying to get my Gtk# program to successfully pass its command-line
arguments to gtk_init (int *argc, char ***argv). Right now Gtk#
expresses the P/invoke call as:

	static extern void gtk_init (ref int argc, ref string[] argv)

Whenever I call this function with a managed array, I get crashes. A
simple test case seems to indicate that argv pointer is not being
marshalled as expected. Anyone know how to properly get this function to

(It seems sometimes that if I just pass the string[] given to my Main
function, the code won't crash, but this isn't acceptable because
gtk_init expects argv[0] to be the program name, which isn't the case
for the arguments to a C# program.)


Peter Williams                          peter at newton.cx

"[Ninjas] are cool; and by cool, I mean totally sweet."
                              -- REAL Ultimate Power

More information about the Mono-devel-list mailing list