-->

System.Web.Mvc not functioning as expected after W

2019-01-13 20:27发布

问题:

After yesterday's Windows Update, I seem to have issues building my projects.

Related Windows Updates could be:
ASP.NET MVC 2.0: KB2993939
ASP.NET MVC 3.0: KB2993937
ASP.NET MVC 4.0: KB2993928
ASP.NET MVC 5.0: KB2992080
ASP.NET MVC 5.1: KB2994397

These errors all seem to be related to the System.Web.Mvc namespace of which I checked; it is still being associated with the project under References. What could have gone wrong with my MVC project during the Windows Update, and how should I go about rectifying it?

Here is the log that indicates the updates administered today:

回答1:

The recent updates have incremented version numbers

3.0.0.0 -> 3.0.0.1 and 4.0.0.0 -> 4.0.0.1

I had to remove the reference and re-add (System.Web.Mvc is found in Assemblies >Extensions are of the Add Reference dialogue)



回答2:

I have same problem today after windows update. There is my solution.

Install-Package Microsoft.AspNet.Mvc -Version 5.2.0.0 -Project PROJECTNAME

Also you can try use these code maybe it helps.

Uninstall-Package Microsoft.AspNet.Mvc -Force

Goodluck.



回答3:

There are two ways to fix this:

Option 1: Add Microsoft.AspNet.Mvc using NuGet

Use NuGet to add the latest revision of the MVC version you depend on to your project. Microsft recommends this approach.

Option 2: Update assembly reference

If you add a new assymbly reference to your project you'll see that the System.Web.Mvc assemblies are now versioned x.0.0.1.


Source: http://blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx

I would suggest against bluntly attempting reinstalling MVC. Allthough it worked for me in the end, you'll run into trouble with NuGet being bundled with the MVC installer.

You need to uninstall NuGet prior to reinstalling MVC because NuGet still being present causes the MVC installer to refuse to install or to fail.

In addition I don't see why reinstalling MVC will prevent Windows Update from applying the update again after you reinstalled MVC.



回答4:

As the patch has incremented the version number has risen from (for MVC4 it has risen from 4.0.0.0 to 4.0.0.1) the Reference Path in the project files needs to change from:

<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\bin\System.Web.Mvc.dll</HintPath>
</Reference>

to

<Reference Include="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\bin\System.Web.Mvc.dll</HintPath>
</Reference>

Obviously adjust the hint path as appropriate, and make similar changes for other versions of MVC



回答5:

We have the same problem.
Microsoft changed the Version from 3.0.0.0 to 3.0.0.1
I guess this is the reason Visual Studio can't find the reference, because the regular setting is "Use specific version - true".
In my case i can't change the setting to false, because I am using Mvc4 on the same machine and it would automatically use the version 4 dll.

A solution is to remove the project reference of System.Web.Mvc.dll and add it again. Then VS will use the Version-3.0.0.1-DLL as a reference.



回答6:

Reinstall the MVC assembly

download link : http://www.microsoft.com/en-US/download/details.aspx?id=30683



回答7:

I tried mh28's solution, which proposed the following:

The recent updates have incremented version numbers

3.0.0.0 -> 3.0.0.1 and 4.0.0.0 -> 4.0.0.1

I had to remove the reference and re-add (System.Web.Mvc is found in Assemblies >Extensions are of the Add Reference dialogue)

On top of that, it was also suggested that I run a Find and Replace throughout my scope of interest; I tried that, but failed. Seems like Find and Replace doesn't apply to .csproj files.

What I did next was to find a text replacing tool (see Ecobyte Replace Text) and run the program using the following settings:

All my projects built as per normal thereafter, and I'm not seeing any side effects (despite not making any changes in the web.config files). I'm not sure (and I don't think) this is the best solution, and I don't think this is a silver bullet for all System.Web.Mvc issues affected by the security-related Windows Update for .NET, but I think it'd be useful for specific cases whereby there're a whole lot of projects to re-reference.



回答8:

Try to install/repair ASP.NET MVC using the last versions of MSI packages available from here.

If you use bindingRedirect in web.config it could be required (it was not needed in my projects) to update the sections too. See the answer. It all still not helps I would recommend to examine other web.config files in your project, like ~/Views/web.config for example.



回答9:

I had same issue recently.

After Windows Update - my project in Visual Studio suddenly had 500+ errors - all related to system.web.mvc

So I deleted the reference and re-added it - found in C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies

Great - project compiles.

Put it on site - get "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

After much messing around, I went to site, downloaded the version of it off there - referenced it - it worked on my laptop AND on site

phew!!!!!!!



回答10:

This issue was present for me. However, the fix was much more simplified than using nuget to fix or making updates to web.config. My issue was resolved by manually updating the text in {ProjectName}.csproj from

Reference Include="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"

to

Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" , and checking in the changes, and running a build in the build agent machine, which, for me, was TeamCity.

Even though this caused build errors locally, it resolved the source control/Team City build errors.

I realize that this doesnt allow me to build locally, without having making changes to the csproj file. However, after I checkin the change as I did above(changing it from 3.0.0.1 to 3.0.0.0), I can update the project locally to use the new version (3.0.0.1), and just not check in the changes to csproj. I imagine someone may have a similar scenario.