1

When I try to use an extension method in the Immediate or Watch windows, I get the following error:

{method} is not a member of {class}

I'm using Visual Studio Community 2013 Update 4, but the issue exists on multiple PCs here, running varying versions of Visual Studio 2013 and 2015.

It makes no difference whether the extension methods come from the .NET BCL, or are defined in our project. The code itself compiles and runs successfully; the issue is only in Immediate and Watch.

I tried setting all projects to framework 4.5.1, and using the x86 configuration, without result.

Adding Imports System.Linq at the beginning of the code file makes no difference (which makes sense, as System.Linq is already globally imported (Project properties -> References -> Imported namespaces)).

What else can be done?

Zev Spitz
  • 13,950
  • 6
  • 64
  • 136
meni
  • 53
  • 1
  • 5
  • Refer to the following question: http://stackoverflow.com/questions/8850286/can-extension-methods-be-called-from-the-immediate-window Regards – Simon Mattes May 10 '15 at 10:23
  • sorry for omitting that link. yes ive seen that page and the only idea there is to add a using/imports. which did not help. ive edited my question to show that. any other ideas? – meni May 11 '15 at 08:45
  • @SimonMattes This issue would seem to be related to some conflict from the class library shared between all our projects. When I created a new project, without the shared library, I don't have this issue. Further, when I add the compiled DLL of the shared library as a reference to the new project, I also do not have the issue. – Zev Spitz Feb 03 '16 at 06:53

1 Answers1

0

In any context where System.Linq isn't imported you can call the extension methods as normal static methods instead. So for example, the following did not work for me in the QuickWatch window (where actualVariables is a List):

actualVariables.Select(x=>x.Identity.DisplayName)

Change it to this form and then it works:

System.Linq.Enumerable.Select(actualVariables,x=>x.Identity.DisplayName)
Stephen Klancher
  • 1,374
  • 15
  • 24