1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ASP.NETでダウングレードをした後に起こるエラーについて(見つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。 )

Posted at

依存関係が複雑なパッケージを複数使って開発をしていると、よく依存関係の問題が発生します。そのような問題についての対処についてです。

前提

ASP.NETで、NuGetを用いてパッケージ管理をしている。

まず確かめること

 依存関係が壊れてしまった場合は、パッケージを全て再インストールしてみると治ることが多々あります。特にNuGetを使ってる際はとても簡易的に可能です。
 パッケージファイル(/package)とバイナリファイル(/project/bin)を削除し、公式の手順に従って再インストールを試みてください。

メソッドやプロパティが発見できない

 後方互換性が無い・意図せず消失してしまったなどの場合は、やむを得ずダウングレードが必須になってくる場合があります。
image.png
NuGetのパッケージ
ダウングレードした後、「ファイルまたはアセンブリ (パッケージ名)、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。」などのエラーメッセージが見られる場合があります。この場合は、web.configで指定しているパッケージのリダイレクトが上手く修正できていないことが多いです。

Web.config
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

としていた場合、古いバージョンはバージョン11.0.0にリダイレクトされます。ダウングレードしていた場合は当然11.0.0のDLLは存在しないため、エラーが発生します。
 リダイレクトを指定する部分をインストールしたバージョンに指定してあげることでこれは回避することができます。

Web.config
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.1.0" newVersion="9.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?