CSC : warning CS1685: The predefined type ‘System.Runtime.CompilerServices.ExtensionAttribute’ is defined in multiple assemblies in the global alias
Posted May 9, 2014
Reading time: 1 minute
In one of my ASP.NET MVC 5 projects that targets .NET 4.5.1
, I noticed that I was getting a new compiler warning at build time:
|
|
On a hunch, I fired up JetBrains dotPeek, loaded all of the assemblies in my bin
directory, and did a Type search (Navigate
-> Go to Everything / Type...
). It turns out that Json.NET actually implements its own version of ExtensionAttribute
:
|
|
Back in my web project, I looked at the properties for Newtonsoft.Json
and noticed that the Runtime Version
was set to v2.0.something
. After reading through this Json.NET discussion thread on the matter, I decided to reinstall the NuGet package:
|
|
And voilà! Newtonsoft.Json
’s properties once again showed that Runtime Version
points to v4.0.30319
, and the compiler warning went away. This modified my .csproj file, and diffing it immediately revealed the source of the problem. Newtonsoft.Json
’s hint path had somehow been set to this:
|
|
Instead of this:
|
|
Hope this helps.