1

I am trying to build a fairly large solution and one static class with some extension functions gives me a bit of a headache. I will simplify the code a lot, basically it boils down to following:

There is a

public static typeP Convert(this typeD d, typeA a, typeB b) {
  return somethingOfTypeP;
}

and there is a

public static IList<typeP> Convert(this IList<typeD> d, IList<typeA> a, IList<typeB> b) {
  return d.Select(x => x.Convert(a.FirstOrDefault(), b.FirstOrDefault()).ToList();
}

So, practically an extension method that does something and another one that extends the idea to a list.

typeA and typeB have a great-grandfather which sits in a package which is not referenced by this project, but obviously is referenced where it is immediately needed (in its children's project).

Everything works great on all of my colleagues' machines, everything builds and the "grandfather's dll" is nicely copied to this project's binary folder upon build - everything's awesome. But on my machine, I get

The type GreatGrandfather is defined in an assembly that is not referenced.
You must add a reference to assembly Greatgrandfathers.assembly, version=... etc.

..on the call to the first Convert, in the Select(lambdaExpression).

So I am really confused by this, actually. If the types are nicely resolved in one place (definition of both Convert methods), why is there a problem with the call from x => x.Convert(...)? Also, why is it only a problem on my computer and nowhere else? I don't see anything that is radically different, same target frameworks, same packages that get pulled down (nuget from a local package source). If I do add the package with Grandfathers.assembly, everything builds and works, but if I make this change, I need to understand why I need it... Any ideas, anyone?

Yuri Makassiouk
  • 425
  • 3
  • 16
  • I had this happen on a project I was working on. It was triggered by branch switching on the local git repo. clean + rebuild did not help. I had to delete all Bin and Obj folders in the solution folder. Once that was done the build ran without problems. – Thomas K May 24 '19 at 11:52
  • Have you tried suggestions from https://stackoverflow.com/questions/20660999/the-type-is-defined-in-an-assembly-that-is-not-referenced-how-to-find-the-cause ? – Renat May 24 '19 at 11:55
  • I did try the "git clean -xfd" approach to later rebuild everything - no luck. I saw that the mentioned package had 2 different versions in several projects across the solution but even consolidating those and again cleaning and rebuilding everything didn't help, so now I've exhausted the options I saw so far... – Yuri Makassiouk May 28 '19 at 06:15

1 Answers1

0

Check the physical path of the reference in the .csproj file for the project that references Grandfather.dll. It could be that your colleagues have the reference configured for a path that is different than the path on your machine.

jbrown7061
  • 103
  • 1
  • 4