CodeRunner 2 中的 C# 汇编

标签 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.运行程序

最佳答案

此错误意味着 CodeRunner 找不到 Mono 的二进制文件之一,它应该在您的 $PATH 上找到它:

gmcs: command not found

gmcs 是 Mono C# 编译器,但它是比当前发布的版本更旧的旧名称。现代 Mono 总是使用名为“mcs”的编译器。 gmcs 应该只是一个运行 mcs 的 shell 脚本,以实现向后兼容性。它也是从/usr/bin 到它真正所在的/Library/Frameworks 的符号链接(symbolic link)。像这样:

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

但是,在最近的一些 Mono 发行版上,这在 Mac OS X 上无法正确部署。在我的例子中,/Library/Frameworks/Mono.framework/Commands/gmcs 不存在!也许也适合你。

因此,为了简单地解决这个问题并让事情自己运行,您可能只想简单地更改符号链接(symbolic link)以指向 mcs?

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

这有点难看,而且会让你的系统变脏。只需修改CodeRunner的compile.sh以使用mcs而不是gmcs就不会那么难看。这并不完全等同,因为 gmcs shell 脚本实际上使用一些可选参数调用 mcs,使其表现得像旧版编译器,但对于您执行 CodeRunner 内容的情况来说,它可能是无害的。

关于CodeRunner 2 中的 C# 汇编,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32144847/

相关文章:

c# - 无法在 Azure 存储上创建容器

c# - 如何从 winforms 按钮单击事件调用异步方法?

ios - 在 iOS 上安装 react-native-firebase 的问题

ios - 在按钮点击时为选定的行设置动画

C#:使用匿名函数排序

ios - 以编程方式添加的按钮在 ios 中不显示触摸感

xaml - ListView 在 iOS 上无法正确显示

android - 在 Xamarin Android 应用程序中集成和使用 .pkpass 通行证

xaml - 在 xamarin 中更改导航栏标题位置

c# - 如何在 msbuild 命令行参数中设置 publishName/AssemblyName?