404 Resource not found on all views

114 Views Asked by At

I have an old project that I have never worked with and need to get running which is using .NET Framework 4.6.

  1. Had warnings about misssing references (Antrl3.Runtime, EntityFramework. ExcelDataReader and many more)
  2. I used the Update-Package -reinstall command in Nuget package manager console which seems to have resolved these warnings
  3. I launch the app but get a Not Found - HTTP ERROR 404. The requested resource is not found.

If I set a breakpoint in the Home controller and try to access one of the controllers methods through the url path then it does not hit the breakpoint and still gives me the requested resource is not found error.

If I right click on a View -> View in Browser it also gives me the same 404 error page. If I open my Home -> Index.cshtml view then an error shows up: > "Severity Code Description Project File Line Suppression State Error CS1980 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference? 1_Views_Home_Index.cshtml 1 Active" If I open a different view I get another error: Severity Code Description Project File Line Suppression State Error CS0012 The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 2_Views_EditData.cshtml 25 Active

I've tried cleaning, rebuilding the project, setting the target framework version to a previous one and then setting it back to 4.6, changing the Microsoft.AspNet.MVC package version but that did not help. Not sure where to look for the problem, in the Solution Explorer the References do not have any warnings or errors. Any advice on how to diagnose this issue?

1

There are 1 best solutions below

8
jmvcollaborator On

What VS version are you using? There is not enough information you might need to downgrade the MVC package version but first try the following with a clean version of the old project.

With regards to the first error:

CS1980 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference? 1_Views_Home_Index.cshtml

Change framework 4.6 back to 4.5.* (try: 4.5.2), then set it back to 4.6 Do a clean build (also try restoring Nuget packages)

With regards to the second error:

CS0012 The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0

Add a reference to System.Core 4.0.0.0 and close/reopen the cshtml.