Ambiguous type 'FormatterAssemblyStyle' when using Json.NET 10.0.1 with netcoreapp2.0 or netstandard2.0
See original GitHub issueNewtonsoft.Json defines System.Runtime.Serialization.Formatters.FormatterAssemblyStyle
in it, while this type is brought back in NetStandard2.0 in System.Runtime.Serialization.Formatters.dll
. So when using this type in a project that targets netcoreapp2.0
or netstandard2.0
and references Json.NET 10.0.1
, you will get the following error at compilation:
Program.cs(18,31): error CS0433: The type 'FormatterAssemblyStyle' exists in both 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'System.Runtime.Serialization.Formatters, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\apps\netcore2\test\test.csproj]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Newtonsoft.Json dependency in a .Net Standard 2 ...
I've experienced the same problem. I am maintaining an asp.net core 2.0 project which references two nuget packages, which I also maintain.
Read more >Package Newtonsoft.Json 10.0.1 is not compatible with ...
The solution opens and it tries to restore packages, and then I get this error. I've uninstalled all Visual Studio installations and .NET...
Read more >Migrate from Newtonsoft.Json to System.Text.Json - .NET
Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json.
Read more >Newtonsoft Json package
0 -preview.12 has newtonsoft JSON in its .Runtime forlder, which is causing issues when using something that depends on the com.unity.nuget.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are now running into this in Xamarin Workbooks trying to port from some rather involved
[Serializable]
,ISerializable
,IObjectReference
,SerializationBinder
code toNewtonsoft.Json
now that we can move all of our targets tonetstandard2.0
.Given that targeting
netstandard2.0
will provide the type, I do not see why you could not remove your version in thenetstandard2.0
copy ofNewtonsoft.Json.dll
as part of the 10.x major release series?In case anyone else is trying to use this assembly in a NetStandard2.0 libary, here are the options: