在全局命名空间中找不到类型或命名空间名称“Xamarin”

时间:2015-03-13 01:39:58

标签: xamarin

我刚刚下载了Xamarin(适用于Windows)。创建了一个新的C#/移动应用程序/空白应用程序(Xamarain.Forms Portable)解决方案。试图编译(我没有做任何更改),我得到错误:

The type or namespace name 'Xamarin' could not be found in the global namespace

我想我希望这可以开箱即用,所以不确定为什么不这样做。

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

            global::Xamarin.Forms.Forms.Init (this, bundle);

            LoadApplication (new App ());
        }
    }
}

2 个答案:

答案 0 :(得分:2)

听起来你错过了你的Xamarin.Forms软件包。

您可以在解决方案资源管理器中展开Packages目录,看看它是否在那里?

首次创建新项目时,它会使用NuGet获取它。

如果您在那里看不到任何内容,可以右键单击Packages文件夹,然后选择Add Packages,并搜索Xamarin.Forms

安装它可以解决您的问题。

答案 1 :(得分:1)

只需从Xamarin.Forms添加Tools -> NuGet Package Manager -> Manage NuGet Package For Solution并搜索Xamarin.Forms并安装到您的项目中。