C# Xamarin跨平台应用程序解决方案构建失败?
我对Xamarin的形式是完全陌生的。我想我要问的问题不会太好,但我面临的问题很奇怪,我不知道如何解决它 问题: 我在visual studio 2017中创建了一个全新的跨平台项目。 a编写了一些代码,当我运行我的应用程序时,构建解决方案失败了 MainPage.xamlC# Xamarin跨平台应用程序解决方案构建失败?,c#,xamarin.forms,C#,Xamarin.forms,我对Xamarin的形式是完全陌生的。我想我要问的问题不会太好,但我面临的问题很奇怪,我不知道如何解决它 问题: 我在visual studio 2017中创建了一个全新的跨平台项目。 a编写了一些代码,当我运行我的应用程序时,构建解决方案失败了 MainPage.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
<?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>
错误:
包括所有必要的using语句,当我单击
在构建解决方案时,它给了我这个错误
- 找不到类型或命名空间名称“System”(是否缺少) a使用指令或程序集引用。)
- 找不到类型或命名空间名称“Xamarin”(是否缺少) a使用指令或程序集引用。)
- 未定义或导入预定义类型“System.Void”。等等
谢谢。这个项目很好,所以问题与代码无关(除非你在App.Xaml和App.Xaml.cs中有什么奇怪的东西) 您可能需要:
- 清理项目
- 还原Nuget包
如果问题仅出现在单一平台上,您可能需要检查与Mac的连接,或者查看是否已安装所有必需的Android SDK/组件。错误消息是什么?如果构建失败,则应该有一些解释性错误消息告诉您原因。另外,
Text:“Say Hello!”
无效,您的意思是Text=“Say Hello!”
未引用命名空间“System”的类型,以此类推@Joe SeweliCicked=“Button_Clicked”
,除了拼写错误的Clicked属性外,其余代码看起来正常。
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;
}
}
}