KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a following issue. I have a solution that contains about 40 projects. There is a project A that references project B that references project C. There isn't any code in project A that uses classes from project C. However, if I use any LINQ extension method in any code, e.g.: var r = new int[] { 1, 2, 3 }.Where(a => a > 1); I get compiler error: somefile.cs(70,13): error CS0012: The type 'XXX' is defined in an assembly that is not referenced. You must add a reference to assembly 'Project C assembly name, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxx'. The error is on the line that uses linq extension method. I'm using VS2010, .NET 3.5. Update: It happens with every extension method. I have created a class in the same file, that looks like this: public static class SomeClass { public static int[] Test(this int[] a) { return a; } } And then I write this code and compilation breaks with same error: new int[] { 1, 2, 3 }.Test(); Update2: Ok, I found out what causes the error. But I don't know why. Following code causes error: using System.Linq; using B; namespace TestApp { public class A { public void M() { var c = new string[] { "a", "b", "c" }.Where(s => s != null); } } } But if I remove using B (I'm stil following the names from my description that A references B, B references C) it compiles. This is the ONLY code in project A. It compiles if I remove usage of extension method or if I remove "using B" as I said before. Update3: First of all, thanks for all your suggestions. The smallest example I can come up with is the following. I created a new project, csproj looks like this (nothing has been changed, only C proj
Tags (comma-separated)
Save Edits
Cancel