我正在尝试使用 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/