Xamarin跨平台应用程序解决方案构建失败



我是Xamarin表单的新手。我想我要问的问题不会太好,但我面临的问题非常奇怪,我不知道如何解决它。

问题:我在visualstudio2017创建了一个全新的跨平台项目。a写了一些代码,当我运行应用程序时,构建解决方案失败了。

主页.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HelloWorld"
x:Class="HelloWorld.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Label x:Name="_label"  Text="Welcome to Xamarin.Forms!" 
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Entry x:Name="EnterYourName" Placeholder="Write your name"/>
<Button Text="Say Hello !" Clicked="Button_Clicked" />
</StackLayout>
</ContentPage>

主页.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Form;
namespace HelloWorld
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
void Button_Clicked(object sender, EventArgs e)
{
_label.Text = "Welcome" + " " + EnterYourName.Text; 
}
}
}

错误:

所有必要的using语句都包含在内,当我单击在构建解决方案时,它给了我这个错误。。。

  • 找不到类型或命名空间名称"System"(是否缺少using指令或程序集引用。)
  • 找不到类型或命名空间名称"Xamarin"(是否缺少using指令或程序集引用。)
  • 未定义或导入预定义类型"System.Void"。等等

如何解决此问题?我将非常感激。

谢谢

这个项目很好,所以问题与代码无关(除非你在App.Xaml和App.Xaml.cs中有一些奇怪的东西)。

您可能需要:

  • 清理项目
  • 恢复Nuget包

如果问题仅出现在单个平台上,您可能需要检查与Mac的连接,或者查看是否已安装所有必需的Android SDK/组件。

最新更新