[英]Xamarin - The type or namespace name 'App' could not be found
Currently getting this error trying to run my Xamarin app to my iPhone live player.当前尝试将我的 Xamarin 应用程序运行到我的 iPhone 实时播放器时遇到此错误。
"AppDelegate.cs(1,1): error: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)"
My solution builds without errors, so slightly stuck.我的解决方案构建没有错误,所以有点卡住了。 These errors did not occur until after I updated to the most recent update.
这些错误直到我更新到最近的更新后才发生。 Any help is greatly appreciated.
任何帮助是极大的赞赏。
App.xaml.cs:应用程序.xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COCApp;
using Xamarin.Forms;
namespace COCApp
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
AppDelegate.cs AppDelegate.cs
using System;
using System.Collections.Generic;
using System.Linq;
using COCApp;
using Foundation;
using UIKit;
namespace COCApp.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
}
I had a similar issue for Android and iOS but mine would build and run just fine except there was a red underline under App on both projects.我在 Android 和 iOS 上遇到了类似的问题,但我的构建和运行都很好,只是两个项目的 App 下都有一个红色下划线。
I fixed it by right clicking on Android References->Add Reference->Projects then unchecking the already included shared project clicking OK.我通过右键单击 Android References->Add Reference->Projects 然后取消选中已包含的共享项目单击确定来修复它。 Then I re-added the shared project and that fixed the error.
然后我重新添加了共享项目并修复了错误。
Note that PCL is no longer a thing when starting a Xamarin.Forms project in newest Visual Studio version, its .Net Standard now.请注意,在最新的 Visual Studio 版本(现在的 .Net Standard)中启动 Xamarin.Forms 项目时,不再需要 PCL。
It seems like it's because of how you name the project.似乎是因为您如何命名项目。 Mine was called 'Project Name' but in References it was imported as 'Project_Name' which didn't exist so I just deleted that reference and added a correct one by going to Android References->Add Reference->Projects.
我的被称为“项目名称”,但在引用中它被导入为不存在的“Project_Name”,所以我只是删除了该引用并通过转到 Android 引用->添加引用->项目添加了一个正确的引用。 Now when I create new file namespace is like 'Project Name' and has errors so I ended up recreating the project but this time without spaces in name
现在,当我创建新的文件命名空间时就像“项目名称”并且有错误,所以我最终重新创建了项目,但这次名称中没有空格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.