xaml - "The type or namespace name ' 应用程序 ' could not be found"Xamarin 表单

标签 xaml xamarin xamarin.android

我正在尝试使用 Visual Studio 在 Xamarin Android 中使用 Xamarin Forms 创建一个简单的应用程序,但是每次尝试构建时我都会收到此错误。我仔细检查了应包含 Portable 项目的引用资料,并确保我拥有最新版本的 Xamarin.Forms。我还缺少什么会导致此错误?

using System;

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using App2;

using Xamarin.Forms.Platform.Android;

namespace App2.Droid
{
    [Activity(Label = "App2", Icon = "@drawable/icon", MainLauncher = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity :
        global::Xamarin.Forms.Platform.Android.FormsApplicationActivity // superclass new in 1.3
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            LoadApplication(new App()); // method is new in 1.3
        }
    }
}

最佳答案

就我而言,如果文件名中存在破折号,我发现在使用生成的代码制作跨平台 Xamarin Form 应用程序时,Visual Studio 2017 会出现错误。

看起来它试图对标题进行蛇形大小写,然后提示找不到该文件。

例如,对于“my-project”,它开始在生成的代码的某些区域中查找“my_project”。

使用不带符号的项目名称似乎可以解决问题。

关于xaml - "The type or namespace name ' 应用程序 ' could not be found"Xamarin 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43898891/

相关文章:

c# - 在 Xamarin.Forms 中编写特定于设备平台的代码

c# - 如何通过代码生成WPF控件

xaml - 如何使用x :bind inside ControlTemplate in UWP

xamarin - 如何在 Xamarin Forms WebView 中加载本地 HTML 文件

android - 如何创建默认应用程序实例的自定义实例?

android - TensorFlow 对象检测在 Xamarin Android 上失败并出现 reshape 问题

mono - 寻找用于跨平台开发的最佳 PCL 配置文件

WPF TextBlock.TextTrimming 不适用于自动调整大小的 ColumnDefinition

c# - 如何在 WPF 中居中对齐组合框所选项目

c# - 反编译.Net代码: lambda expressions