Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试在Ubuntu 20.04的VS代码中运行C代码时出现脚本错误_C#_.net_Visual Studio Code - Fatal编程技术网

C# 尝试在Ubuntu 20.04的VS代码中运行C代码时出现脚本错误

C# 尝试在Ubuntu 20.04的VS代码中运行C代码时出现脚本错误,c#,.net,visual-studio-code,C#,.net,Visual Studio Code,[运行]scriptcs/home/yash/netcore/netcore/Program.cs /bin/sh:1:脚本:未找到 [完成]在0.012秒内退出,代码为127如果要运行mono或Microsoft.NET软件,而不是从Debian软件包安装,则需要安装mono complete 然后,nstall mono完成。在所有当前受支持的Ubuntu版本中,打开终端并键入: sudo apt install mono-complete 将C代码保存在名为hello.cs的文件中。示例

[运行]scriptcs/home/yash/netcore/netcore/Program.cs /bin/sh:1:脚本:未找到


[完成]在0.012秒内退出,代码为127

如果要运行mono或Microsoft.NET软件,而不是从Debian软件包安装,则需要安装mono complete

然后,nstall mono完成。在所有当前受支持的Ubuntu版本中,打开终端并键入:

sudo apt install mono-complete
将C代码保存在名为hello.cs的文件中。示例hello.cs代码是: 使hello.cs可执行。右键单击hello.cs文件->选择属性->权限选项卡->在允许以程序形式执行文件的左侧打勾

使用cd命令将目录更改为包含hello.cs文件的目录

使用mcs编译器,从源hello.cs创建名为hello.exe的Windows可执行文件:

mcs -out:hello.exe hello.cs
使用mono运行hello.exe程序:

mono hello.exe
在步骤6中运行程序的结果。应该是:

你好,世界

按Enter键退出返回默认端子提示

反编译可执行文件

monodis --output=decompiled-hello.txt hello.exe

您的代码可能未编译,因为您没有在计算机上安装或设置编译器。您需要安装C和.NET核心SDK的运行时编译,然后使用终端运行代码。下面是一些可以帮助您设置此功能的说明。否则,您可以安装Visual Studio,当您运行代码时,它将负责自己的编译。

使用ProjectName.csproj打开文件夹并键入dotnet Run。您还可以为生成和运行配置任务。按F5,VS将为您配置它。当dotnet core可用时,为什么要使用mono?mono不再是Linux开发的最佳方式,它可能是一种在存储性能ram较少的系统上运行得更好的替代方案。。等