9

Intellisense not working for any razor html tags. Also showing Red line in all razor html tags (@Html.TexBox, @Html.DropdownList MultiSelect etc)

Three types error are showing in Visual Studio Error Window.

Error #1:

The type arguments for method 'System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>, System.Collections.Generic.IDictionary)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Error #2:

One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?

Error #3:

Error 40 The type arguments for method 'System.Web.Mvc.Html.InputExtensions.HiddenFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Please see the attached link for more information.

enter image description here
enter image description here

xlecoustillier
  • 16,183
  • 14
  • 60
  • 85
Rakin
  • 1,271
  • 14
  • 30
  • Show us your code. We don't know what you did wrong if you don't show us what you did. – DPac Oct 01 '15 at 14:20
  • I've seen Intellisense get out of sync for Razor files. Usually closing and opening VS fixed it. Have you tried that? Also, it seems by default if there's an error in your view, it doesn't fail the build, so you have to manually notice these compilation issues. See my answer [here](http://stackoverflow.com/a/28346348/1139830) for a resolution on that. – mason Oct 01 '15 at 14:22
  • Please see the the link [link](http://s10.postimg.org/4h9ukt6y1/error.jpg) [link](http://s24.postimg.org/novf33kid/error.jpg) – Rakin Oct 01 '15 at 14:22
  • I generally would restart VS, clean solution and finally rebuild. – Tez Wingfield Oct 01 '15 at 14:24
  • still problem persist – Rakin Oct 01 '15 at 14:41

4 Answers4

8

Problem solved deleted all the contents from the following folder.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

Thank you all for your time. :)

Rakin
  • 1,271
  • 14
  • 30
1

You need to have following section in your web.config (Root should be fine)

    <system.web>
        <compilation debug="true" targetFramework="4.6.1">
            <assemblies>
                <add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </assemblies>
       </compilation>
    </system.web>

Replace System.Web.Helpers version as per your reference.

Anil
  • 21
  • 5
  • I had a similar problem with System.Linq (part of System.Core assembly). Finally after hours of searching, this was the solution that worked. @Anil, much appreciation. – Aron Boyette Feb 24 '19 at 22:05
0

That happens to me from time to time, usually rebuilding the project which contains the errors works for me. Did you try that?

Let me know.

0

If the close and rebuild doesn't sort it I suspect there is an issue with your project file.

Create a new ASP.net web app and copy your files over. A bit of a pain but it will probably work.

CF5
  • 1,123
  • 9
  • 19
  • cant do it . Working in TFS – Rakin Oct 01 '15 at 14:39
  • Give it a go and see if it works, if it does you could probably look at the differences between the two project files and manually update the one you have in TFS. Has it always done it? – CF5 Oct 01 '15 at 14:52