0
votes

I'm currently dealing with a problem on a ASP.NET MVC4 Application, I did a change of .NET Framework (from 4.5 to 4 then to 4.5 again) and it updated my NuGet packages so my Web.config is all messed up and i can't get rid of those errors that the YSOD shows me. Can you explain me a bit what can i do to correct those errors ?

Here's the error i get.

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\5ccfcdb0\4d5a6f51\assembly\dl3\5f700272\1350df4e_ebe9ce01\System.Web.WebPages.Razor.dll'.

1
Removed bad language. Try and keep it civil, no matter how much you're banging your head against the desk :)Moo-Juice
Try to run the command Add-BindingRedirect in the Nuget-prompt. Maybe a binding redirect can solve this.Mikael Östberg
Sorry for the language :)Revv
Welcome to the club. I've searched the entire solution for ANY instance of 2.0.0.0 and found NOTHING! There's not one single reference to ANY assembly with a 2 in it anywhere in my solution let alone System.Web.WebPages.Razor. I've also checked the actual version number of all the assemblies from the System.Web.WebPages namespace and they're all 3.0. 1. Uninstalled the MVC package from Nuget and reinstalled it. 2. Removed the assemblyBinding elements from Web.config. 3. Cleaned/rebuilt the solution. 4. Unloaded the solution and looked through the .proj file for any references.Ami Schreiber

1 Answers

0
votes

Okay i solved my problem by myself.

I updated manually in the Web.config (from the Views Folder) the configuration to Version=3.0.0.0 and the version of the MvcWebRazorHostFactory (same file) to Version=5.0.0.0