Currently getting this error trying to run my Xamarin app to my iPhone live player.
"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:
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
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);
}
}
}
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. 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
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.
I fixed it by right clicking on Android References->Add Reference->Projects then unchecking the already included shared project clicking OK. 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.
Check your project to make sure it has a reference to the PCL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With