C# 生成的代码隐藏引发System.ArgumentNullException

C# 生成的代码隐藏引发System.ArgumentNullException,c#,xaml,xamarin.forms,C#,Xaml,Xamarin.forms,当我尝试在Xamarin表单中使用XAML创建内容视图时,生成的代码会引发以下错误: System.ArgumentNullException: Value cannot be null. Parameter name: clrNamespace at this.LoadFromXaml(typeof(MyXamlPage)); at InitializeComponent() XAML: 您只需添加xmlns=”http://xamarin.com/schemas/2014/forms“到

当我尝试在Xamarin表单中使用XAML创建内容视图时,生成的代码会引发以下错误:

System.ArgumentNullException: Value cannot be null. Parameter name: clrNamespace
at this.LoadFromXaml(typeof(MyXamlPage));
at InitializeComponent()
XAML:



您只需添加
xmlns=”http://xamarin.com/schemas/2014/forms“
到您的根元素。引发此错误是因为没有为根元素定义名称空间,因此解析器无法确定正在解析的XML类型。

Sweet answer bro!
<ContentPage
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Adapt.Presentation.XamarinForms.MyXamlPage"
         Title="My Xaml Page">
    <ContentPage.Content>
        <Grid>
        </Grid>
    </ContentPage.Content>
</ContentPage>