How can I fix this error at creating new page?

耗尽温柔 提交于 2020-07-20 04:33:12

问题


I have a Xamarin.Forms Project.

In this project I already had a blank page but I added a new one, is when the error started showing.

The errors that show are:

Error XLS0414
The type 'ContentPage' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
TaskX.Android New.xaml
1 

Error XLS0414  The type 'StackLayout' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
TaskX.Android New.xaml
10 

EDIT
This is the code:

<ContentPage>
    x:Class="TaskX.New"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TaskX"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"

    <StackLayout>

    </StackLayout>

</ContentPage>

回答1:


I encountered this problem a while ago. Try these steps below, they worked for me.

  1. Remove Xamarin.Forms and Re-Install Xamarin.forms.

  2. Update all your Nugets packages.

  3. Clean and Build solution.

If the problem persists :

  1. Restart your Visual Studio and/or your PC.

  2. Make sure your Visual Studio is up-to-date and you do not have any pending windows updates to do.

  3. Repair Visual Studio.

  4. You can also clear NuGet cache from 'C:\Users{User}\AppData\Local\NuGet\Cache'




回答2:


Try this:
All the referencing will be inside <contentPage> tag.

<ContentPage
   x:Class="TaskX.New"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="using:TaskX"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d">

   <StackLayout>

   </StackLayout>

</ContentPage>


来源:https://stackoverflow.com/questions/51600664/how-can-i-fix-this-error-at-creating-new-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!