Conflicting versions of ASP.NET Web Pages detected

2019-03-22 13:31发布

I am getting the following error after installing microsoft web helper:

Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0". To continue, remove files from the application's bin directory or remove the version specification in web.config.

From what I read, I might have tried instaling the wrong version. But how do i orrect this? So far, I have

  • uninstall the microsoft web helper
  • Deleted and content of the bin folder and rebuild the project
  • Replace my web.config file with a new file with all defaults (given i did not change much here or my project.

But none of these (as suggested online) worked. Any hint on how to solve this please. Ihave been at this for hours now

3条回答
2楼-- · 2019-03-22 13:46

This is just an addendum to Dave's answer but don't forget to change this in all the Views folders also, if you haven't. The best thing probably is to use the "Replace in Files" feature from VS (Ctrl+Shift+H) to ensure you didn't miss any occurrence.

查看更多
祖国的老花朵
3楼-- · 2019-03-22 13:50

I'd like to add the following:

In my case, I was able to fix it the following way. First (important!), I changed the target framework to 4.6.1, reloaded the solution, then upgraded the binary packages by using NUGET.

Then, after fixing the issue as described by the solution above, I got additionally the errors:

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred creating the configuration section handler for system.web.webPages.razor/host: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

The relevant part of the root Web.config was looking like this:

<configSections>
    <sectionGroup name="system.web.webPages.razor" 
            type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, 
            System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35">
    <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, 
            System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, 
            System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  </sectionGroup>

After changing that to:

  <configSections>
    <sectionGroup name="system.web.webPages.razor"  
        type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, 
            System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35"  >
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, 
            System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35"  />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, 
            System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, 
            PublicKeyToken=31BF3856AD364E35"  />
    </sectionGroup>
  </configSections>

it was instantly working.

Note that:

  • I also changed the property copy local to true for each System.Web.* assemblies.

  • In some projects, the section group sectionGroup name="system.web.webPages.razor" might as well be missing - you need to add it in that case.

  • If you plan to upgrade to MVC 4, first upgrade to MVC 3 before you do the final step, because there are some breaking changes in MVC 4 (see details here).

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-03-22 13:55

I had this issue after upgrading to VS 2013 Express Preview.

Then I noticed there was a line in web.config that was:

 <add key="webpages:Version" value="1.0.0.0" />

Changed it to the version of system.web.webpages.dll in my bin folder:

 <add key="webpages:Version" value="3.0.0.0" />

...and the problem went away. (in your case I guess it's 2.0.0.0.)

查看更多
登录 后发表回答