Conflicting versions error adding ASP.NET MVC 3 We

2019-06-22 08:57发布

问题:

I am getting the following error creating a new project after installing Windows Azure Tools 1.4:

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.

回答1:

You'll find you have an assembly in your bin folder that is a different version from the one mentioned in the web.config. The weird bit is that it may not be the assembly that the message suggests. It may be a descendent of that.

I had this problem whereby it claimed version of System.Web.WebPages in the bin folder was 2.0.0.0 but it was definitely 1.0.0.0 when I checked. It then turned out that it was System.Web.WebPages.Deployment that was version 2.0.0.0. After removing that assembly the error went away. I wrote a blog post on this: Conflicting versions of ASP.NET Web Pages detected



回答2:

I had this problem and it drove me nuts. The simple solution was to delete everything out of my bin directory (Build Clean wasn't enough) and then rebuild. I needed no programming changes.

This problem occurred for my after a co-worker upgraded a project to MVC4.



回答3:

I also had this problem and it would redeploy the files to my bin every time I did a build. Finally I figured out that I had to remove them from my _bin_deployableAssemblies also. That fixed it for me.



回答4:

I encountered the same problem, but the root cause was slightly different. This one was a little tricky to solve. The project had the correct 1.0.0.0 DLL version for System.Web.WebPages and the correct configuration in the Web.config. However, the System.Web.WebPages.Deployment and System.Web.WebPages.Razor DLLs were referencing version 2s instead of Version 1s.

My coworker's solution was magically referencing the correct versions when mine didn't initially. When I looked at the project file, the Version was to 2, but the hint path for the DLLs were to Version 1. So, when he opened the solution Version 1 was used, but on mine Version 2 was used. I guess the hint path made the difference here.

What was checked in:

<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll</HintPath>
  <Private>True</Private>
</Reference>

After fixing it:

<Reference Include="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />