开发者

LINQ not working in Views. Any ideas how to fix this?

System.Linq doesn't seem to be referenced in any of my v开发者_StackOverflow中文版iews, even though it is. Any LINQ code in any of my views appears as it does in this image, and Intellisense doesn't work

LINQ not working in Views. Any ideas how to fix this?

However, the LINQ code does work in all of my .cs files, and the code in the views still works when I run the solution.

when I hit Alt+Enter I get a little message "Failed to import method".


Make sure you have Linq referenced in Pages section of web.config

 <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <namespaces>
        ........... 
        <add namespace="System.Linq" />
        ................
      </namespaces>
    </pages>


I would check these in the following order -

  1. System.Linq reference in the project references.
  2. Target Framework should be .NET 3.5 or Above
  3. Is the file ReadOnly ?


Ensure the DLL does not have "copy local" set to False - worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜