I'm pretty new to working with more than one project in a solution. I have two projects: AutoPoster.Droid and AutoPoster.Core.
In AutoPoster.Droid I have an adapter class that references LocationInfo in AutoPoster.Core. I'm now getting this error and not sure why:
The type or namespace 'Core' could not be found (are you missing a using directive or assemblu reference?)
Here is my code:
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();
}
}
}
You can't use namespaces like that. You can't specify just part of a namespace, from after AutoPoster
. You either need a using
directive for AutoPoster.Core.Model
:
using AutoPoster.Core.Model;
namespace AutoPoster.Droid.Adapters
{
public class PostInfoAdapter : BaseAdapter<LocationInfo>
{
...
}
}
Or you need to fully qualify the classname:
namespace AutoPoster.Droid.Adapters
{
public class PostInfoAdapter : BaseAdapter<AutoPoster.Core.ModelLocationInfo>
{
...
}
}
EDIT: And yes, you do actually have to have a reference from one project to the other...
See more on this question at Stackoverflow