Assembly reference cannot be resolved - dependentAssembly issue?

The issue was something unexpected.

The fix was to include the following line in the project file under each relevant <PropertyGroup> section:

<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>

To edit the project file, right click on the project and click on Unload Project. Now right click on the unloaded project and choose Edit MyProject.csproj


If you have scrubbed your project files, package files, and references and all versions are the correct and latest version of Newtonsoft, it could be a .Net dll with a dependency to an earlier version of Newtonsoft.Json. In my case it was System.Net.Http.Formatting, Version=4.0.0.0:

enter image description here

Try adding the following to the *.config of the calling project:

<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>

When running a test project against the WebAPI project, a FileNotFound exception was being thrown from the WebAPI because of a Newtonsoft.Json version mismatch between 4.5.0.0 and 6.0.1.0. Adding the statement to the app.config of the calling test project fixed the issue.