-1

我有一个使用 Monodevelop 3 和 MonoMac 库创建的带有 GUI 的 C# 应用程序。构建后,我得到了一个带有嵌入式单声道 v3 运行时的 mac 应用程序。

应用程序运行良好,但它没有收到我传递给它的任何命令行参数。

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

我试过通过他们使用

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

甚至直接运行生成的可执行文件

/Applicaitons/My.app/Contents/MacOS/MyApp my_command_line_arg
4

3 回答 3

0

在 MonoMac 应用程序包中,实际的“应用程序”通常是一个 shell 脚本,AFAIK 它不会将它的参数传递给可执行文件。

我认为目前这是不可能的;我听说有人通过使用环境变量来解决这个问题。

于 2013-03-15T10:44:27.313 回答
0

我用最新版本的 Xamarin Studio(4.2.2,build 2)和 MonoMac 尝试了这个,它工作得很好。似乎 MonoMac 曾经有一个错误,现在已修复。

于 2014-02-11T13:36:33.907 回答
-1

如果通过 shell 脚本调用 MonoMac 应用程序,则可以将命令行参数传递给它。从运行 Mono 应用程序

(...) 如果您有“myprogram.exe”,您可以创建一个名为“myprogram”的 shell 脚本,其中包含以下内容:

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

当您运行“myprogram”时,shell 会将 $@ 替换为您提供的任何参数。

这适用于我在 Xamarin Studio 中构建的 MonoMac 应用程序。

于 2013-04-18T14:04:57.397 回答