找到的程序集清單定義與程序集引用不匹配


“/”應用程序中的服務器錯誤。


未能加載文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)

說明: 執行當前 Web 請求期間,出現未經處理的異常。請檢查堆棧跟蹤信息,以了解有關該錯誤以及代碼中導致錯誤的出處的詳細信息。 

異常詳細信息: System.IO.FileLoadException: 未能加載文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)

程序集加載跟蹤: 下列信息有助於確定程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”未能加載的原因。

 

警告: 程序集綁定日志記錄被關閉。
要啟用程序集綁定失敗日志記錄,請將注冊表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD)設置為 1。
注意: 會有一些與程序集綁定失敗日志記錄關聯的性能損失。
要關閉此功能,請移除注冊表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

可是小豬不知道是啥時候引用了該死的這個4.5.0.0版本啊!!

這可折騰死小豬了!!不知道是何種原因,各種百度谷歌,最后還是看到老外的一個解釋:

 

引用:
It's not clear what the relationships of the projects are, or when this error is occuring, but here's a guess. You have 3 projects the facebook project (refs 4.0.0.0 version), twitter project (refs 4.0.3.0 version), and a main project that refs both of those projects. You may be able to build this solution, but when you run the assembly binding will fail. Why? because the default behavior is to copy assemblies locally before running. What happens is that the first project to build copies to bin (say twitter) then the second project builds (facebook), then main. However, at the end of this the 4.0.0.0 version is sitting bin folder. When you run, as soon as you invoke something from twitter that tries to use the problem assembly the bind fails because it longer has access to the 4.0.3.0 version of the assembly. There are a couple of ways around this. One is register both assemblies in the GAC. If that isn't doable then look into assembly binding redirection in your config file. Another is to register for theAssemblyResolve event and load the assembly programmatically.

然后小豬按照其大概的方法增加了這么一句:

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

OK了。這真是個蛋疼的下午!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM