1

I updated Visual Studio with update 4 before updating all packages via NuGet. Now when I try to run my website I get this error:

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)

After checking the error list I saw this warning:

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

After setting verbosity setting to Detailed I got this (and some more considered .... text:

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.

There is indeed no log4net files or whatsoever. I guess something is using this assembly? Is there a way to auto detect assembly issues and fix them? Because this is way to technical for me.

What I think is weird is that my newsoft.json reference indicates a Version 4.5.0 and the error states it needs a 6.0.0.0 and my package.config says it contains a 6.0.8 version.

I particularly have the JSON issue.

Kraishan
  • 443
  • 5
  • 14
  • 38
  • possible duplicate of [Found conflicts between different versions of the same dependent assembly that could not be resolved](http://stackoverflow.com/questions/24772053/found-conflicts-between-different-versions-of-the-same-dependent-assembly-that-c) – trailmax May 09 '15 at 19:51
  • I think I have a particular JSON issue. – Kraishan May 09 '15 at 19:56
  • You have 2 references to 2 different Json.Net dll versions. Probably you have updated nuget in one project, but older version is used in other project of the same solution. Just try the instructions in the linked question. – trailmax May 09 '15 at 19:58
  • In my solution I only have 1 project. So that cannot be the case. – Kraishan May 09 '15 at 20:20

2 Answers2

1

Most probably there are no conflicts, just a missing assembly, in your particular case Newtonsoft.Json. Since the views are compiled on demand, that is, just before displayed for the first time, you may need to add MvcBuildViews to your project file (open it as a xml file, not a project) like this: Compile Views in ASP.NET MVC. Another option is to install the RazorGenerator nuget package to check if view(s) compile.

What is important, however, that once the problem is spotted (the missing Newtonsoft.Json) you need to make it available and correctly referenced by your project.

You may need to "Enable NuGet Package Restore" for the solution, if not done already. If, however, you still get this error the package Manager Console comes to help. Just issue the command in Package Manager Console:

PM> Update-Package Newtonsoft.Json -Reinstall

Reinstall is required in order to keep the same package version as the original (in packages.config). If you do not care about the version you may safely omit it.

Well, uninstalling then installing the package again works of course, but is too much of a trouble to do it if you often face such a problem.

Community
  • 1
  • 1
Alexander Christov
  • 9,625
  • 7
  • 43
  • 58
0

If you're still experiencing problems then go for the -Force option.

Uninstall-Package Newtonsoft.Json -Force
Install-Package Newtonsoft.Json
Matt Canty
  • 2,395
  • 5
  • 35
  • 50