簡體   English   中英

無法加載文件或程序集-反射堅持加載舊版本

[英]Could not load file or assembly - reflection insist loading an old version

在Visual Studio(2013)中運行單元測試時,出現以下錯誤。

System.IO.FileLoadException:無法加載文件或程序集“ Newtonsoft.Json,版本= 6.0.0.0,區域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed”或其依賴項之一。 找到的程序集的清單定義與程序集引用不匹配。 (來自HRESULT的異常:0x80131040)

Newtonsoft.Json是我引用的DLL。 但有趣的是,我在所有地方都引用了Newtonsoft.Json 7.0。 我很困惑,為什么反射堅持要加載舊版本6.0。

關於我可以從哪里開始調查的任何提示?

謝謝,

我將檢查您的web.config文件,以查看是否存在引用舊版本的文件。

您也可以嘗試將其添加到web.config以確保使用正確的版本。 我將其放在<system.web>標簽之后

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

        </assemblyBinding>
    </runtime>
</configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM