The type 'RangeTree<,>' is defined in an assembly that is not referenced.
erotavlas opened this issue · 3 comments
I have added RangeTree 1.0.5 to a class library project targeting .NET 4.5.2 using NuGet. The reference seems to be ok and I am able to create the Range item, comparer and so on.
public class RangeItem : IRangeProvider<int>
{
public Range<int> Range { get; set; }
public NamedEntity entity { get; set; }
}
public class RangeItemComparer : IComparer<RangeItem>
{
public int Compare(RangeItem x, RangeItem y)
{
return x.Range.CompareTo(y.Range);
}
}
Then in my main class I create an instance of RangeTree
public class projectAtype
{
public RangeTree<int, RangeItem> rTree;
public myClass(){
rTree = new RangeTree<int, RangeItem>(new RangeItemComparer());
...
}
....
}
Then I have a WPF project targeting the same version of .NET 4.5.2. and I add a project reference to the class library project
Inside the code behind of MainWindow, I can create an instance of the class library type
public partial class MainWindow : MetroWindow
{
projectAtype myClass = new projectAtype();
public MainWindow()
{
InitializeComponent();
myClass.rTree.Add(..... <--cannot access rTree object inside myClass instance
}
}
The result is this
I cannot access the rTree property. It says I need to adda reference to RangeTree in the WPF application.
Are you working with Visual Studio 2015? If yes, I will try to see if I can reproduce (and hopefully fix) this issue.
Yes VS 2015
Later on I was thinking maybe this is correct behavior? To use it that way don't I need a reference in the WPF app anyway because to add items to the data structure I need to create RangeItem objects. I can't do that without a reference to the library in the WPF app.
In the end however my solution was to create a wrapper method for Add, Query, etc...that I call from the WPF app, that way there is no need to create the RangeItem from there and the Range Tree is entirely invisible from that project.
Yes, abstracting Add, Query etc. is definitely the right way to go. Otherwise you will need the reference. I'm therefore closing this issue now.