Weird Error Updating ASP.NET MVC from 4 to 5

I am converting my project from MVC 4 to MVC 5 (and .Net 4 to .Net 4.5.2, which is the real change driver.)

When I start one of my pages, I get this error (empty space added by me to make reading easier)

[A] System.Web.WebPages.Razor.Configuration.HostSection cannot be added to [B] System.Web.WebPages.Razor.Configuration.HostSection.

Type A is taken from "System.Web.WebPages.Razor, Version = 1.0.0.0, Culture = Neutral, PublicKeyToken = 31bf3856ad364e35 'in the" Default "context in place.' C: \ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Web.WebPages.Razor \ v4.0_1.0.0.0__31bf3856ad364e35 \ System.Web.WebPages.Razor.dll '

Type B is taken from "System.Web.WebPages.Razor, Version = 3.0.0.0, Culture = Neutral, PublicKeyToken = 31bf3856ad364e35 'in the" Default "context in the location' C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ studentportal3g \ 2204bad2 \ aece9b3b \ build \ DL3 \ ad80387c \ 91adbf51_fc73d101 \ System.Web.WebPages.Razor.dll ".

When I first saw this, Not much :)

I looked through each project and made sure that its version was updated to MVC 5, which has version 3.0.0.0 of System.Web.WebPages.Razor.dll.

Clear recovery, still get an error. No problem, I will delete cached temporary file files.

, . , System.Web.WebPages.Razor.dll , . , dlls, , .

DLL DLL, "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET

Files\studentportal3g...

dll? ? ?

,

-

+3
2

Visual Studio - , , , , MSBuild. , , ( ) .csproj, .

, GAC NuGet, , , , - System.Web.WebPages.Razor version 1.0.0.0, 3.0.0.0.

  • node Unload Project.
  • node Edit <projectName>.csproj.
  • System.Web.WebPages.Razor HintPath ( ). , HintPath .
  • ( , DLL, ).

<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>

<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>

web.config /Views/web.config, , .

. , , , . , , - . , DLL.

.

+5

, DLL (GAC). GAC - , , , . , GAC.

gacutil GAC.

- "Microsoft SDKs" Program Files.

C:\Program Files (x86)\Microsoft SDK\Windows\v10.0A\bin\NETFX 4.6.1 \

cmd gacutil. :

gacutil.exe -i [path to your assebly] -f.

-i , . -f , .

, DLL

C:\Temp\System.Web.WebPages.Razor.dll

gacutil.exe -i "C:\temp\System.Web.WebPages.Razor.dll" -f

+1

All Articles