2015-05-09 93 views
1

在更新所有通過NuGet的包之前,我更新了帶有更新4的Visual Studio。現在,當我嘗試運行我的網站,我得到這個錯誤:在VS和NuGet更新後,無法加載文件或程序集netwonsoft.json

An exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll but was not handled in user code

Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

檢查錯誤列表後,我看到了這樣的警告:

Warning 14 Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 1697 5 Project

設置冗長設置爲詳細我這後(有的更多考慮....文字:?

1> Could not resolve this reference. Could not locate the assembly "log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 
1> For SearchPath "projectfolder\bin". 
1> Considered "projectfolder\bin\log4net.winmd", but it didn't exist. 
1> Considered "projectfolder\bin\log4net.dll", but it didn't exist. 
1> Considered "projectfolder\bin\log4net.exe", but it didn't exist. 

確實是有沒有log4net的文件或任何我想的東西是使用該組件是否有辦法來自動檢測裝配問題和解決這些問題因爲?這是對我來說技術的方式。

我覺得很奇怪的是,我的newsoft.json引用指出版本4.5.0,錯誤指出它需要6.0.0.0,我的package.config說它包含6.0.8版本。

我特別有JSON問題。

+0

的[不同版本的相同依賴性組件,其不能被解析的實測值之間的衝突(可能重複http://stackoverflow.com/questions/24772053/found-conflicts-between-different-versions-of -the-same-dependent-assembly-that-c​​) – trailmax

+0

我想我有一個特定的JSON問題。 – Kraishan

+0

您有2個引用2個不同的Json.Net dll版本。可能你已經在一個項目中更新了nuget,但是舊版本用於相同解決方案的其他項目中。試試鏈接問題中的說明。 – trailmax

回答

1

在您的特定情況下,極有可能不存在衝突,只是缺少程序集Newtonsoft.Json。由於視圖是按需編譯的,也就是說,在第一次顯示之前,您可能需要將MvcBuildViews添加到項目文件(以xml文件打開,而不是項目),如下所示:Compile Views in ASP.NET MVC。 另一種選擇是安裝RazorGenerator nuget包來檢查視圖是否編譯。

但是,重要的是,一旦發現問題(缺少Newtonsoft.Json),您需要將其提供並正確引用您的項目。

您可能需要爲解決方案「啓用NuGet包恢復」(如果尚未完成)。但是,如果您仍然遇到此錯誤,那麼包管理器控制檯會提供幫助。就在包管理器控制檯發出命令:

PM> Update-Package Newtonsoft.Json -Reinstall

重新安裝,以保持與原來相同的封裝版(packages.config)是必需的。如果你不關心版本,你可以放心地忽略它。

那麼,卸載然後重新安裝軟件包當然是有效的,但如果你經常遇到這樣的問題,那麼做太麻煩了。

0

如果您仍遇到問題,請轉至-Force選項。

Uninstall-Package Newtonsoft.Json -Force 
Install-Package Newtonsoft.Json 
相關問題