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

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

    I did ALL of the above and in the end found that what solves it for me (on a .net framework 4.7.1 site with MVC 5.2.4) was adding this into the root web.config within <compilation> -

    <assemblies>
      <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    </assemblies>
    
    0 讨论(0)
  • 2020-12-24 04:53
    • Close the file
    • Clean the solution
    • Build the solution
    • Reopen the file
    0 讨论(0)
  • 2020-12-24 04:54

    I have tried most of these, what eventually worked for me was unloading the project, edit the csproj file, and add the following:

    <Reference Include="System.Core" />
    

    https://stackoverflow.com/a/38371981/2335660

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

    I've had the same problem with missing assembly and it happened that VS2017 build has not copied it properly into the Bin folder. These steps helped me:

    • Navigate to the web project's References node
    • Find the reference to System.Core
    • Open the VS Properties Window
    • In the properties window, change Copy Local: False to True

    from this comment: CS0012: The type '#####Any type#####' is defined in an assembly that is not referenced

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

    I have run in the same issue as you, albeit much later. The issue was that I was not able to access Razor views (.cshtml) as I was getting an error stating that I had a missing assembly reference, namely System.Web.Mvc, even though it was in the project references. After investigation, I have noticed that the installed NuGet version was 5.2.3, while the project required 5.2.0. The solution is to downgrade the MVC version.

    1. Go to Project-> NuGet Package Manager.
    2. Search for MVC; it's going to be the first result.
    3. Next is to select downgrade from the drop-down in the details of the NuGet package and submit.

    Confirm all the dialogs and you are ready to go.

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

    This happened with one of my views - all the others were fine. I did the following:

    • Create a new view
    • Copy and paste the contents from the old view to the new one
    • Deleted the old one
    • Renamed the new one to the old one
    0 讨论(0)
提交回复
热议问题