2015-07-15 3 views
1

Я пытаюсь обновить MVC4 до MVC5, но происходят странные вещи. Я использовал a pretty nice guide that I found и все компилируется нормально, но когда я пытаюсь показать сайт, я получаю эту ошибку:проблемы с обновлением MVC4 до MVC5

Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Странная вещь, что, когда я смотрю на ссылки сборки на System.Web.Mvc, System.Web .Razor, System.Web.WebPages и т. Д., Они все еще находятся на номера версий, принадлежащих MVC4! Я пытался переустановить соответствующие пакеты NuGet, который дал мне вид продукции вы надеетесь получить:

PM> Update-Package -reinstall -Id Microsoft.AspNet.Razor 
Removing 'Microsoft.AspNet.Razor 3.2.3' from LabManager.Web. 
Successfully removed 'Microsoft.AspNet.Razor 3.2.3' from LabManager.Web. 
Uninstalling 'Microsoft.AspNet.Razor 3.2.3'. 
Successfully uninstalled 'Microsoft.AspNet.Razor 3.2.3'. 
Installing 'Microsoft.AspNet.Razor 3.2.3'. 
You are downloading Microsoft.AspNet.Razor from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. 

Successfully installed 'Microsoft.AspNet.Razor 3.2.3'. 
Adding 'Microsoft.AspNet.Razor 3.2.3' to LabManager.Web. 
Successfully added 'Microsoft.AspNet.Razor 3.2.3' to LabManager.Web. 

, который предполагает, что установлены правильные версии. Однако, по-прежнему ссылка System.Web.Razor показывает, что она находится на версии 2.0.0.0. Кроме того, я компилирую для .NET версии 4.5.1, но версия Runtime System.Web.Razor по-прежнему показывает 4.0.3.0319. То же самое касается всех связанных с MVC ассемблеров (кроме того, что номер версии для System.Web.Mvc равен 4.0.0.0 вместо 5.x.x.x).

Помощь! Кто-нибудь знает, что здесь происходит?

Edit: Вот мой Web.Config:

<?xml version="1.0" encoding="utf-8"?> 
<!-- 

For more information on how to configure your ASP.NET application, please visit 
      http://go.microsoft.com/fwlink/?LinkId=152368 
      --> 
<configuration> 
    <configSections> 

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> 
    <connectionStrings> 
    <add name="LabManagerEntities" connectionString="metadata=res://*/Models.LabManagerEntities.csdl|res://*/Models.LabManagerEntities.ssdl|res://*/Models.LabManagerEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLServer;Initial Catalog=mne_labbeheer_prd1;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /> 
    <add name="ApplicationServices" connectionString="Data Source=.\SQLServer;Initial Catalog=mne_labbeheer_prd1;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="webpages:Version" value="3.0.0.0" /> 
    <!--<add key="webpages:Enabled" value="false" />--> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    <!-- IP addresses allowed to view IP Address Restricted portions of the website. 
      An asterisk indicates an entire subnet is valid. --> 
    <add key="AuthorizeIPAddresses" value="::1,127.0.0.1" /> 
    </appSettings> 
    <!-- 
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367. 

    The following attributes can be set on the <httpRuntime> tag. 
     <system.Web> 
     <httpRuntime targetFramework="4.5.1" /> 
     </system.Web> 
    --> 
    <system.web> 
    <globalization culture="en-US" /> 
    <compilation debug="true" targetFramework="4.5.1"> 
     <assemblies> 
     <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </assemblies> 
    </compilation> 
    <authentication mode="Forms"> 
     <forms loginUrl="~/Account/LogOn" timeout="2880" /> 
    </authentication> 
    <membership defaultProvider="DefaultMembershipProvider"> 
     <providers> 
     <clear /> 
     <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> 
     </providers> 
    </membership> 
    <profile defaultProvider="DefaultProfileProvider"> 
     <providers> 
     <clear /> 
     <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /> 
     </providers> 
    </profile> 
    <roleManager enabled="true" defaultProvider="DefaultRoleProvider"> 
     <providers> 
     <clear /> 
     <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" /> 
     <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /> 
     </providers> 
    </roleManager> 
    <pages controlRenderingCompatibilityVersion="5.0"> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     </namespaces> 
    </pages> 
    <httpRuntime maxRequestLength="104857600" /> 
    <!-- 
      If you are deploying to a cloud environment that has multiple web server instances, 
      you should change session state mode from "InProc" to "Custom". In addition, 
      change the connection string named "DefaultConnection" to connect to an instance 
      of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. 
     --> 
    <sessionState mode="InProc" customProvider="DefaultSessionProvider"> 
     <providers> 
     <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /> 
     </providers> 
    </sessionState> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="RoleManager" /> 
    </modules> 
    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="104857600" /> 
     </requestFiltering> 
    </security> 
    </system.webServer> 
    <system.data> 
    <DbProviderFactories> 
     <remove invariant="System.Data.SqlServerCe.4.0" /> 
     <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> 
    </DbProviderFactories> 
    </system.data> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    <!-- When targeting ASP.NET MVC 3, this assemblyBinding makes MVC 1 and 2 references relink 
      to MVC 3 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it. 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
     --> 
    <!-- When targeting ASP.NET MVC 3, this assemblyBinding makes MVC 1 and 2 references relink 
      to MVC 3 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it. 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
     --> 
    </runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
</configuration> 
+0

Вы можете показать свой web.config? – Kamo

+0

отредактировал мой вопрос – jkokorian

+0

Очистить и перестроить? Перезапустить VS? – SayusiAndo

ответ

0

Оказывается, что упомянутые узлы, где не те установленных пакеты mvc5 NuGet, но куча старых в папке называется «_bin_deployableAssemblies». Я просто удалил эту папку, и визуальная студия выяснила, где взять новые. Номера версий связанных с MVC сборок отображаются правильно, и приложение работает как шарм.

2

У вас есть проблемы с связывающим переадресовывает, они должны быть следующими:

<dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
    </dependentAssembly> 

В текущем наборе до Helpers и WebPages точки до версии 2, Mvc указывает на версию 4.

Вам также необходимо будет проверить все ваши взгляды web.config, чтобы сделать уверен, что они также используют правильные версии.

Я использовал это руководство, чтобы обновить свои приложения:

How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2

+0

Спасибо, что указали на них, я их не замечал! Однако это не решило проблему (но это сделало ее по меньшей мере :)) – jkokorian

+1

@jkokorian спасибо. У меня была такая же проблема, как и ваше решение. :) Я забыл об этом. – hutchonoid

+0

Кажется, я смутно помню, что у меня было то же самое, когда я обновил MVC3 до MVC4 два года назад: S. Если я правильно помню, эта папка использовалась, если ваш веб-сервер не установил необходимые сборки. Это все еще проблема, когда все пакеты на основе nuget? – jkokorian

Смежные вопросы