Weird Error Upgrading ASP.NET MVC from 4 to 5

Weird Error Upgrading ASP.NET MVC from 4 to 5

Visual Studio is a great tool, but it doesn't always make the right choices when it comes to upgrading dependencies, nor does it support every possible option available in MSBuild. Whenever you find yourself in a bind such as this you should manually review and (if necessary) edit your .csproj file in order to resolve it.

The problem isn't that your file exists in the GAC or that it has not been installed by NuGet, the issue is most likely that one of your project files still has a reference to the old version of System.Web.WebPages.Razor version 1.0.0.0, and you need to find all references to it and change them to 3.0.0.0 accordingly.

  1. Right-click on your project node in Solution Explorer and click Unload Project.
  2. Right-click the project node again and click Edit <projectName>.csproj.
  3. Search the file for references to System.Web.WebPages.Razor and update the version and the HintPath accordingly (as shown below). Make sure the HintPath you use actually points to an existing file.
  4. Repeat these steps for all dependent projects in the solution (and any that are in DLLs that are not part of the solution).

Old Reference

<Reference Include="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
</Reference>

Updated Reference

<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>

You should also go through the web.config and /Views/web.config files to ensure that they are not referencing any old versions of this assembly.

NOTE: If the above instructions don't solve your issue, the issue likely is outside of your solution. Most likely there is a 3rd party library that is referencing the old version of the file somewhere. If so, you could attempt to get an updated version of the DLL.

You may also want to check out this question.

problems upgrading MVC4 to MVC5

It turns out that the referenced assemblies where not the ones installed by the mvc5 nuget packages, but by a bunch of old ones in a folder called '_bin_deployableAssemblies'. I simply removed that folder and visual studio figured out itself where to get the new ones. The version numbers of the MVC related assemblies appear correctly now and the application runs like charm.

Complications when upgrading from ASP MVC 3 Preview 1 to beta

After intense searching I found some answers in the ASP.NET MVC 3 release notes. There is a section called Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3 which tell you what to do:

Add the two following lines into your <assemblies> section in your web.config:

<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31BF3856AD364E35" />

<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />

BundleTable error with new ASP.NET MVC 4 project

It looks like you have .NET Framework 4.5 Developer Preview installed (this is where System.Web.Optimization.BundleTable in System.Web.dll is coming from) and ASP.NET MVC 4 Beta is not compatible with it (you can read release notes here: http://www.asp.net/whitepapers/mvc4-release-notes)



Related Topics



Leave a reply



Submit