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” in ASP.MET MVC 3

夙愿已清 提交于 2019-12-12 07:39:23

问题


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


回答1:


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




回答2:


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:


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



来源:https://stackoverflow.com/questions/13892868/conflicting-versions-of-asp-net-web-pages-detected-specified-version-is-1-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!