I have a couple of projects that all include the json.net 6.0.3 NuGet package. When I add:
using Newtonsoft.Json;
I get the following error when building:
1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: Unhandled exception (3.1.48.0, 32 bit, CLR 4.5, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed'. [Version mismatch] 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: ============ PostSharp Assembly Loading Log =================== 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Finding the assembly with binding identity 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Found file 'F:\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll' with identity 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=msil'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Reference mismatch for 'F:\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll' [VersionMismatch]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Found file 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.dll' with identity 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=msil'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Reference mismatch for 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.dll' [VersionMismatch]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=x86. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=msil. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: The assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed' was not found. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: =============================================================== 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.^5YpB0scd(BindingOptions _0) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.ExecuteProjects() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
I was unable to find any references to "'newtonsoft.json, version=4.5.0.0," in the project, not sure why it is looking for that.
I tried setting the "Build Host" PostSharp project property to managed but still got the same exception.
Turns out that while the exception was coming from PostSharp the remedy was updating all the NuGet packages.