我已经安装了 monodevelop 并在 C# 控制台中编写了一个 hello world 程序,但是在运行配置中我选择“在外部控制台中运行”复选框并单击运行按钮 monodevelop 说:无法执行“{项目路径}”
操作系统:Debian、Kali 2
编辑:和 Console.ReadLine() 在默认运行配置中不起作用。
我也遇到了同样的问题,这是我的解决方案。
操作系统:Linux Mint 18.1 Cinnamon 64 位
Monodevelop:6.1.2.44 flatpak 安装
afaik MonoDevelop 需要 xterm 或 gnome-terminal 才能在外部控制台中运行程序。如果两者都缺失,您会收到“无法执行...”错误。
MonoDevelop日志显示:
~/.var/app/com.xamarin.MonoDevelop/cache/MonoDevelop-6.0/Logs/Ide.log
ERROR [2017-01-10 19:47:49Z]: Cannot execute "/home/...exe"
System.InvalidOperationException: Cannot start process because a file name has not been provided.
就我而言,我必须安装 xterm 并将其复制到 flatpak 运行时:
sudo apt-get install xterm
cp -v /usr/bin/xterm ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/bin/
cp -v /usr/lib/x86_64-linux-gnu/libXaw* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /usr/lib/x86_64-linux-gnu/libXmu* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /usr/lib/x86_64-linux-gnu/libutempter* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /lib/x86_64-linux-gnu/libpng12* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /lib/x86_64-linux-gnu/libtinfo* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
也许不是最好的解决方案,但它对我有用。
我找到了解决这个问题的几种方法:
1. 不要创建控制台应用程序,而是创建一个
GTK 2.0
项目。例如:
using System;
using Gtk;
namespace Test
{
class MainClass
{
public static void Main(string[] args)
{
/*Application.Init();
MainWindow win = new MainWindow();
win.Show();
Application.Run(); */
Console.WriteLine("Hello World");
}
}
}
在
Application Output pad
中,你会看到“Hello World”。
mono-runtime
(sudo apt-get install mono-runtime
)
并转到 bin/Debug/
目录。在那里你会找到一个 .exe 文件,你可以简单地执行它 ./{{NameOfProject}}.exe
我在 Ubuntu 20.04 上遇到了这个问题(使用来自 PPA 的最新 monodevelop)
因为在20.04,
gnome-terminal-server
已从 /usr/lib/gnome-terminal/
移至 /usr/libexec/
Monodevelop 需要更新才能解决这个问题。
我的临时修复:
cd /usr/lib
sudo mkdir gnome-terminal
sudo ln -s /usr/libexec/gnome-terminal-server
这是“复制 xterm”方法的自动两行代码(在 Ubuntu 16.04 上测试):
ldd `which xterm` | awk '{if ($2 == \"=>\") print $3}' | grep / | xargs -I{} cp -Lnv {} .local/share/flatpak/runtime/org.freedesktop.Sdk/x86_64/1.4/active/files/lib/
cp -nv `which xterm` .local/share/flatpak/runtime/org.freedesktop.Sdk/x86_64/1.4/active/files/bin/
我必须在 Linux Mint Sylvia 中打开一个终端窗口,然后切换到项目名称,然后从那里切换到 bin/Debug 文件夹。我看到有一个由monoDevelop创建的exe。我将exe的模式更改为可执行。然后我通过输入名称.exe 来运行该 exe,它成功了。