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

前端 未结 28 1325
渐次进展
渐次进展 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:56

    Add the following to Web.config (in root). I tried absolutely everything of earlier suggestions and nothing worked until I found the below. Hope it will save time for someone else.

    I use targetFramework="4.6.1", but change it to the version you use if different.

    <system.web>
       <compilation debug="true" targetFramework="4.6.1" />
       <httpRuntime targetFramework="4.6.1" />
    </system.web>
    
    0 讨论(0)
  • 2020-12-24 04:57

    This can be caused if you have multiple projects in your solution that don't all target the same version of the .NET Framework. For example, if your web app project targets .NET 4.5 and you have an assembly reference to another project in the solution that targets .NET 4.5.2. To fix this you need to change your projects to all target the same version of the .NET Framework.

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

    Check that the cshtml file Build Action is set to 'Content'.

    I use ReSharper and have noticed that for some reason the file that is generated defaults to 'None' when invoking the template.

    0 讨论(0)
  • 2020-12-24 05:00

    I just had the same exact issue and none of the solutions fixed the problem. I had to add this into my web.config within System.Web

    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    

    I had removed it when changing some of the config around.

    0 讨论(0)
  • 2020-12-24 05:01

    I am not sure if you are still having this issue or not but i was having the same issue as well.

    I was able to find the solutions here

    https://stackoverflow.com/questions/6496223/compilation-error-in-net-4-0-web-config-linq-not-found

    <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    
    <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    
    <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    

    I hope this helps..

    0 讨论(0)
  • 2020-12-24 05:03

    In Web.config I needed to change:

      <system.web>
        <compilation debug="true" targetFramework="4.7">
    

    to

      <system.web>
        <httpRuntime targetFramework="4.7" />
        <compilation debug="true" targetFramework="4.7">
    
    0 讨论(0)
提交回复
热议问题