c# - 如何修复创建新页面时的此错误?

标签 c# android ios xaml xamarin

我有一个 Xamarin.Forms 项目。

在这个项目中,我已经有一个空白页面,但我添加了一个新页面,此时错误开始显示。

显示的错误是:

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 

编辑
这是代码:

<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. 删除 Xamarin.Forms 并重新安装 Xamarin.forms。

  2. 更新所有 Nugets 软件包。

  3. 清理并构建解决方案。

如果问题仍然存在:

  1. 重新启动 Visual Studio 和/或 PC。

  2. 确保您的 Visual Studio 是最新的,并且您没有任何待处理的 Windows 更新。

  3. 修复 Visual Studio。

  4. 您还可以从“C:\Users{User}\AppData\Local\NuGet\Cache”清除 NuGet 缓存

关于c# - 如何修复创建新页面时的此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51600664/

相关文章:

c# - WCF 双工服务忽略自定义用户名身份验证

android - 位图回收不适用于 android 4.2 或更高版本的 4.2?

ios - React native iOS 字体无法以任何方式工作

android - Spinner 不换行 - 这是一个 Android 错误吗?

android - OpenCV-Android highgui链接错误

ios - 从声明的变量引用核心数据属性

ios - 你能在不同的应用程序之间共享 CloudKit 上的数据吗

c# - 如何在 Blazor WebAssembly-PWA 中运行离线数据库使用?

c# - 为什么要使用 String.Equals 而不是 ==?

c# - 使用简单注入(inject)器注册多个电子邮件输出服务