错误提示I'm缺少using指令或汇编引用,但I'm不是…

本文关键字:引用 不是 汇编 using 提示 缺少 错误 指令 | 更新日期: 2023-09-27 18:14:46

我对在一个解决方案中处理多个项目非常陌生。我有两个项目:AutoPoster。Droid AutoPoster.Core

在AutoPoster

。我有一个适配器类在AutoPoster.Core中引用LocationInfo。我现在得到这个错误,不知道为什么:

类型或命名空间'Core'找不到(您是否缺少using指令或汇编引用?)

下面是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Views;
using Android.Widget;
namespace AutoPoster.Droid.Adapters
{
    public class PostInfoAdapter : BaseAdapter<Core.Model.LocationInfo>
    {
        private readonly Activity activity;
        public List<Core.Model.LocationInfo> LocationInformation { get; private set; } //Getting Error Here
        public PostInfoAdapter(Activity context, IEnumerable<Core.Model.LocationInfo> localInfo)//Getting Error Here
        {
            LocationInformation = new List<Core.Model.LocationInfo>(localInfo);//Getting Error Here
            activity = context;
        }
        public override int Count
        {
            get { return LocationInformation.Count; }
        }
        public override Core.Model.LocationInfo this[int position]//Getting Error Here
        {
            get { return LocationInformation[position]; }
        }
        public override long GetItemId(int position)
        {
            return position;
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView ?? activity.LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem2, null);
            var localInfo = LocationInformation[position];
            var name = view.FindViewById<TextView>(Android.Resource.Id.Text1);
            name.Text = !String.IsNullOrEmpty(localInfo.FullName) ? localInfo.FullName : localInfo.ShortName;
            var rxcui = view.FindViewById<TextView>(Android.Resource.Id.Text2);
            rxcui.Text = !String.IsNullOrEmpty(localInfo.FullName) ? localInfo.ShortName : String.Empty;
            return view;
        }
        public void ReloadData(IEnumerable<Core.Model.LocationInfo> locationInformation)//Getting Error Here
        {
            LocationInformation.Clear();
            LocationInformation.AddRange(locationInformation);
            NotifyDataSetChanged();
        }
    }
}

错误提示I'm缺少using指令或汇编引用,但I'm不是…

不能这样使用名称空间。您不能从AutoPoster之后指定名称空间的一部分。对于AutoPoster.Core.Model,您需要using指令:

using AutoPoster.Core.Model;
namespace AutoPoster.Droid.Adapters
{
    public class PostInfoAdapter : BaseAdapter<LocationInfo>
    {
        ...
    } 
}

或者需要完全限定类名:

namespace AutoPoster.Droid.Adapters
{
    public class PostInfoAdapter : BaseAdapter<AutoPoster.Core.ModelLocationInfo>
    {
        ...
    } 
}

编辑:是的,你实际上必须有一个从一个项目到另一个项目的参考…