当前命名空间中不存在类型或命名空间“App" [英] The type or namespace 'App' does not exist in the current namespace

查看:37
本文介绍了当前命名空间中不存在类型或命名空间“App"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2015 中遇到了一个新制作的 Xamarin.Forms 应用程序的问题.我将 Droid/iOS 项目添加到解决方案中,它给我一个构建错误说...

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...

当前命名空间中不存在类型或命名空间App"

这是两个错误所在的示例.

Here is an example of where the two errors are.

机器人项目:

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 项目:

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);
        }
    }
}

这个解决方案刚刚完成,还没有完成编码,这会是VS2015的问题吗?

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

推荐答案

这是一个仍然存在的问题.虽然这可能不是 7 月份的解决方案,但这是 2016 年 3 月 31 日的有效解决方案.

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.

  • 清洁溶液
  • 构建 PCL
  • 从受影响的项目中删除 PCL 引用
  • 重新添加 PCL 引用
  • 构建

有时在打开 XAML 文件并切换回 PCL 项目中的 C# 文件后也会发生这种情况.

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

这篇关于当前命名空间中不存在类型或命名空间“App"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆