-1

I have a C# application with GUI created using Monodevelop 3 and MonoMac libraries. After build, I get a mac app with embedded mono v3 runtime.

Application runs fine, but it does not receive any command line arguments that i pass to it.

static void Main (string[] args)
{
 // args are always empty
}

I've tried passing them using

open -a /Applicaitons/MyApp.app --args my_command_line_arg

and even just running generated executable directly

/Applicaitons/My.app/Contents/MacOS/MyApp my_command_line_arg
alex
  • 12,464
  • 3
  • 46
  • 67

3 Answers3

0

In the MonoMac application bundle, the actual 'application' is usually a shell script and AFAIK it does not pass it's arguments to the executable.

I don't think this is possible currently; I have heard of people working around this by using environment variables instead.

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • I tried exactly what Alex did and it works just fine. I guess if it works in my project this answer is not quite right. I suppose there is a bug fix in the latest version of MonoMac that resolves the issue observed earlier. – Miroslav Nedyalkov Feb 11 '14 at 13:33
0

I tried this with the latest version of Xamarin Studio (4.2.2, build 2) and MonoMac and it works just fine. It seems that MonoMac used to have a bug which is fixed now.

Miroslav Nedyalkov
  • 1,101
  • 1
  • 10
  • 22
-1

You can pass command line arguments to your MonoMac application if you call it through the shell script. From Running Mono Applications:

(...) if you had "myprogram.exe" you could create a shell script called "myprogram" that had the contents:

#!/bin/sh
/usr/bin/mono /usr/lib/APPLICATION/myprogram.exe "$@"

When you run "myprogram," the shell will replace $@ with any arguments you provided.

This works for my MonoMac application built in Xamarin Studio.

Bojan Komazec
  • 9,216
  • 2
  • 41
  • 51
  • This is an interesting idea, but how can it be applied when mono runtime is embedded in application and is not present separately on the computer? – alex Apr 18 '13 at 20:01