Xamarin Studio 报告使用 GTK 时未找到 Mono.Unix 命名空间#
Xamarin Studio reports Mono.Unix namespace not found when using GTK#
我正在尝试在 Xamarin Studio 中创建一个 GTK# 应用程序,因此我创建了一个 GTK# 解决方案,它使用编辑器生成以下代码
如图所示,它显示了一个错误,指出
"Mono" could not be found.
我也使用 Unity,所以这可能会影响 Mono。
我在 Xamarin Studio
的 OS-X 版本上遇到过同样的事情,但我无法告诉您如何重现它(以及确切的解决方案)。
并且通过使用 xbuild
进行构建基本上会遇到相同的错误,因为生成的 gtk/MainWindow.cs
未正确生成但包含在 MSBuild "Target CoreCompile" 步骤中,因此导致:
MainWindow.cs(8,3): error CS0103: The name `Build' does not exist in the current context
为我解决的是:
- 将项目设置为不使用 MSBuild
- 退出并重新启动
Xamarin Studio
- 全部清除
- 全部构建
- 如果需要,将项目设置回使用
MSBuild
。
这个错误有点误导,并不是说找不到Mono,而是找不到命名空间"Mono.Unix"。该命名空间可以在程序集Mono.Posix中找到,请添加对它的引用并重新编译。
我正在尝试在 Xamarin Studio 中创建一个 GTK# 应用程序,因此我创建了一个 GTK# 解决方案,它使用编辑器生成以下代码
如图所示,它显示了一个错误,指出
"Mono" could not be found.
我也使用 Unity,所以这可能会影响 Mono。
我在 Xamarin Studio
的 OS-X 版本上遇到过同样的事情,但我无法告诉您如何重现它(以及确切的解决方案)。
并且通过使用 xbuild
进行构建基本上会遇到相同的错误,因为生成的 gtk/MainWindow.cs
未正确生成但包含在 MSBuild "Target CoreCompile" 步骤中,因此导致:
MainWindow.cs(8,3): error CS0103: The name `Build' does not exist in the current context
为我解决的是:
- 将项目设置为不使用 MSBuild
- 退出并重新启动
Xamarin Studio
- 全部清除
- 全部构建
- 如果需要,将项目设置回使用
MSBuild
。
这个错误有点误导,并不是说找不到Mono,而是找不到命名空间"Mono.Unix"。该命名空间可以在程序集Mono.Posix中找到,请添加对它的引用并重新编译。