[Mono-dev] mono_add_internal_call to mscorlib method
nicolasbotto at gmail.com
Thu Jun 9 13:37:55 UTC 2016
Hi Robert, thanks for the reply. I didn't explain my self correctly. Here's
an example, I have a c# assembly with a method that prints the args to the
public void Print()
string args = System.Environment.GetCommandLineArgs();
System.Console.WriteLine("Length: " + args.Length);
This assembly is loaded using the mono embedded API. I look for the method
print and I invoke it. This returns 0.
The main issue here is that the System.Environment.GetCommandLineArgs() is
being used by the System.Diagnostics.Trace to get the Application Name,
therefore when you try it in an embedded scenario it blows up.
internal static string get_AppName()
if (appName == null)
appName = Path.GetFileName(Environment.GetCommandLineArgs());
As you can see Path.GetFileName(Environment.GetCommandLineArgs()); throws
System.IndexOutOfRangeException: Index was outside the bounds of the array.
This occurs because the native call is never invoked. That's the reason why
I'd like to add an icall and return an array so it doesn't fail.
Please let me know if you need more info. Is you run this using the mono
command it works because the native call is being invoked, it fails in an
View this message in context: http://mono.1490590.n4.nabble.com/mono-add-internal-call-to-mscorlib-method-tp4667951p4667955.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list