The type 'Expression<>' is defined in an assembly that is not referenced

前端 未结 28 1320
渐次进展
渐次进展 2020-12-24 04:39

In ASP.NET MVC 4.5.2 Framework.

after typing

@Html.LabelFor()
or 
@Html.EditorFor()

in view

I\'m getting Error: The

相关标签:
28条回答
  • 2020-12-24 04:46

    I faced the same problem. Basically the problem is using different version of System.Web.Mvc. So the best thing you should the open Tools > Nuget Package Manager > Manage Nuget Packages for Solution. You can probably see System.Web.Mvc on the Cosolidate tab. Upgrade or downgrade would be the best option. If you use the latest .Net framework, which is currently .Net 4.6.1, you should upgrade the all System.Web.Mvc versions to 5.2.4.0. Good luck!

    0 讨论(0)
  • 2020-12-24 04:46

    Try to add

    using system.Linq.Expressions;

    0 讨论(0)
  • 2020-12-24 04:47

    I had this problem too. Changing targetFramework="4.5.2" to targetFramwork="4.5" in web.config file solved it.

    0 讨论(0)
  • 2020-12-24 04:50

    Restarting Visual studio worked for me.

    0 讨论(0)
  • 2020-12-24 04:51

    This error means that Visual Studio is unable to locate the System.Web.Mvc assembly to power its intellisense for Razor views. One or both of the following may be required to fix it.

    1. Ensure the version of the .NET framework for the compilation property in the main web.config (the one in the website root) is the same as that specified in the project properties.

    [root]/Web.config:

    <system.web>
        <compilation targetFramework="4.6" />
    

    Project Properties:

    1. Ensure the version of the MVC assembly specified in the views web.config (the one in the views folder) is the same as the MVC assembly you are using in your project.

    [views folder]/web.config:

    <system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    

    MVC Assembly Reference Properties:

    0 讨论(0)
  • 2020-12-24 04:51

    delete bin, .vs and obj directory. after build your project on the visual studio.

    0 讨论(0)
提交回复
热议问题