CodeRunner 2中的C#程序集

时间:2015-08-21 16:05:53

标签: c# ios xamarin mono coderunner

我正在使用CodeRunner 2(2.0.3),我无法在C#中编译代码。我收到警告:

/Users/Username/Library/Application Support/CodeRunner/Languages/C#.crLanguage/Scripts/compile.sh: line 25: gmcs: command not found

In order to run C# code, you need to have Mono installed. You can get it at http://mono-project.com

我安装了Mono,我安装了Xamarin Studio并尝试了它。一些基本的东西是有用的,所以我知道Mono就在那里。我已经重新启动了我的计算机,重新启动了CodeRunner等。我在其他StackOverflow答案中做了一些事情但仍然无法正常工作。我试图从THIS示例运行一个简单的URL请求。任何帮助表示赞赏。

提前谢谢!

〜已解决〜 谢谢@clay-fowler

1。打开CodeRunner

2. 将语言设置为C#

3. 粘贴:

using System;
class Untitled
{
    static void Main(string[] args)
    {
        Console.Write ("Hello");
    }
}

4. 转到CodeRunner - >偏好 - >语言 - > C#

5. 在“设置”标签下,单击“编辑脚本...”

6. 将gmcs更改为mcs(第25行)

7。现在应该是这样的:

compname=`echo "$CR_FILENAME" | sed 's/\(.*\)\..*/\1/'`.exe
mcs "$CR_FILENAME" "${@:1}"
status=$?
if [ $status -eq 0 ]
then
echo $compname
exit 0
elif [ $status -eq 127 ]
then
echo -e "\nIn order to run C# code, you need to have Mono installed. You can get it at http://mono-project.com"
fi
exit $status

8。运行程序

1 个答案:

答案 0 :(得分:2)

这个错误意味着CodeRunner找不到Mono的二进制文件,它应该在你的$ PATH上找到它:

gmcs: command not found

gmcs是Mono C#编译器,但它是旧版本的旧名称,而不是目前的版本。 Modern Mono总是使用名为“mcs”的编译器。 gmcs应该只是一个运行mcs以实现向后兼容的shell脚本。它也是一个从/ usr / bin到/ Library / Frameworks的符号链接。像这样:

/usr/bin/gmcs -> /Library/Frameworks/Mono.framework/Commands/gmcs

然而,在最近的一些Mono发行版中,这并未在Mac OS X上正确部署。在我的情况下,/ Library / Frame / Mono.framework / Commands / gmcs不存在!也许对你而言。

因此,要简单地解决这个问题并让自己运行起来,您可能只想将符号链接更改为指向mcs?

sudo ln -s /usr/bin/gmcs /Library/Frameworks/Mono.framework/Commands/mcs

这有点丑,会让你的系统变脏。仅修改CodeRunner的compile.sh以使用mcs而不是gmcs就不那么难看了。这不是完全等价,因为gmcs shell脚本实际上调用了mcs,其中一些可选参数使其行为类似于旧的编译器,但是对于执行CodeRunner的情况,它可能是无害的。