8

According to my source Debugging lamba expression with VS2015, LINQ should work in the debugger's watch window. However, I still receive the following error:

error CS1061: 'IEnumerable<MyClass>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'IEnumerable<MyClass>' could be found (are you missing a using directive or an assembly reference?)

Do I have to turn some option on? How to enable LINQ in the watch window? System.Linq is included via using in the file I'm currently debugging.

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
D.R.
  • 20,268
  • 21
  • 102
  • 205
  • Does it work when you run the code in runtime? – Giannis Paraskevopoulos Dec 14 '15 at 13:06
  • What do you mean by "in runtime"? – D.R. Dec 14 '15 at 13:11
  • i was wandering if you were missing a `using` but it seems not... And i also just noticed that you are trying vs 2015. – Giannis Paraskevopoulos Dec 14 '15 at 13:14
  • When the error occurs you should be able to hover over Linq variable to find out current value(s). The error indicates the Linq variable is not a List<> object. A Where will only work when the variable is a list that can be enumerated. If the object is a class, then you must make the class IEnumerable or add a list object to the class that can be enumerated. – jdweng Dec 14 '15 at 13:26
  • @jdweng: The object is of type `List` and implements `IEnumerable`. – D.R. Dec 14 '15 at 13:42
  • See following posting : http://stackoverflow.com/questions/277150/define-an-extension-method-for-ienumerablet-which-returns-ienumerablet – jdweng Dec 14 '15 at 14:55
  • I don't think you're following my question. I do not want to write an extension method. I want to use *existing* LINQ extension methods in the Visual Studio debugger. `Where()` is defined for `IEnumerable`, it should work. – D.R. Dec 14 '15 at 15:11
  • You may need to make sure that you are using the new compiler – jmoreno Dec 15 '15 at 02:14
  • We're using Roslyn and new C# 6 features, so that cannot be the problem ... though I have to check, I think we're still on .NET 4.5.x, maybe an update to .NET 4.6.x solves the problem...I'll report back! – D.R. Dec 15 '15 at 07:59
  • 1
    No, all settings are the same. I also created a sample solution where it works, there seems to be something specific about my current solution which prevents LINQ in the debugger's watch window... – D.R. Dec 15 '15 at 17:30

1 Answers1

5

I have found the problem: Mono.Cecil-rewritten assemblies do not support extension method evaluation in the debugger (including LINQ extension methods) at the moment. I will extend this answer as soon as I have a workaround.

Here is the link to the Mono.Cecil GitHub issue: https://github.com/jbevain/cecil/issues/90

D.R.
  • 20,268
  • 21
  • 102
  • 205