Подтвердить что ты не робот

Не удалось загрузить файл или сборку "WebGrease" или одну из ее зависимостей

Когда я запускаю свое веб-приложение MVC4, оно выдает следующую ошибку:

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

У меня был web.config как:

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>

После ознакомления с некоторыми ответами о SO я изменил его на:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>

Но все равно это не работает.

В чем может быть проблема?

Изменить:

enter image description here

Изменить 2:

Снова следующая ошибка после установки пакета:

Server Error in '/' Application.

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: Could not load file or assembly 'MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Source Error: 


Line 249:      <providers>
Line 250:        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
Line 251:        <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
Line 252:      </providers>
Line 253:    </membership>
4b9b3361

Ответ 1

У меня была такая же проблема.

Это было разрешено

1) запуск консоли диспетчера пакетов

2) в консоли, введите: "Install-Package Microsoft.AspNet.Web.Optimization"

который разрешил все неправильные зависимости.

Ответ 2

Мне пришлось бежать Update-Package -Reinstall Microsoft.AspNet.Web.Optimization

Это обновило мой web.config и все ссылки

Ответ 3

Проверьте содержимое раздела runtime/assemblyBinding в web.config. Я установил неверно зарегистрированные элементы зависимых элементов после установки пакета Kendo UI. Я вручную удалил дубликаты, и проблема исчезла.

Ответ 4

Заменить:

<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />

Для:

 <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />

Ответ 5

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

Ответ 6

Просто обновите WebGrease до 1.6

PM> Update-Package WebGrease -Version 1.6

Ответ 7

Моя ситуация была такой: отлично работала на моей машине разработчика, но на той же платформе хоста появилась та же самая ошибка "пропущено веб-смазка". Мое решение:
1. Удалил все .dll из каталога \bin
2. Удалены все ссылки из web.config.
3. Когда я обновил домашнюю страницу и получил ошибку "some-next.dll отсутствует", я скопировал этот файл some-next.dll в каталог bin и добавил ссылку на web.config для каждой "свежей" dll

Примечание: посмотрите на свойства WebGrease.dll | вкладка "Сведения" - убедитесь, что версия продукта соответствует <dependentAssembly>. В моем случае это было так:

<dependentAssembly>
  <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-1.5.1.25624" newVersion="1.6.5135.21930" />
</dependentAssembly>