Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace 'App' does not exist in the current namespace

I am having an issue with a newly made Xamarin.Forms app in Visual Studio 2015. I added the Droid/iOS projects to the solution and it is giving me a build error saying...

The type or namespace 'App' does not exist in the current namespace

Here is an example of where the two errors are.

Droid project:

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

            global::Xamarin.Forms.Forms.Init (this, bundle);
                LoadApplication (new MyApp.App ());
                //Error on the above line at MyApp.App ()
            }
        }
}

iOS project:

namespace MyApp.iOS
{
    [Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init ();
            LoadApplication (new MyApp.App ());
            //Error on above line in MyApp.App ()
            return base.FinishedLaunching (app, options);
        }
    }
}

This solution was just made and no coding done yet, could this be an issue with VS2015?

like image 910
Shawn Avatar asked Jul 28 '15 02:07

Shawn


2 Answers

This is an issue that still exists. While this may not have been the solution back in July, this is the working solution for 3/31/16.

  • Clean the solution
  • Build the PCL
  • Remove the PCL reference from the affected project(s)
  • Re-add the PCL reference
  • Build

This also happens sometimes after opening a XAML file and switching back to a C# file in the PCL project.

like image 199
silencedmessage Avatar answered Oct 05 '22 02:10

silencedmessage


You need to reference the Forms PCL project, it will do it by default when you create the project unless you create each project individually. Just Right Click on the MyApp.Droid project -> Add Reference -> Solution -> Check MyApp(?!?!)

like image 39
Felipe Avatar answered Oct 05 '22 00:10

Felipe