mattjohnsonpint / TimeZoneNames

Provides a complete source of localized time zone names and abbreviations.
MIT License
196 stars 32 forks source link

MissingMethodException when using Newtonsoft.Json v5 #32

Closed mattjohnsonpint closed 6 years ago

mattjohnsonpint commented 6 years ago

Currently, the minimum supported version of Newtonsoft.Json is 5.0.5. This compiles, but when using gives an error:

Unhandled Exception: System.TypeInitializationException:
The type initializer for 'TimeZoneNames.TZNames' threw an exception.
---> System.MissingMethodException: Method not found: 'Newtonsoft.Json.JsonSerializer Newtonsoft.Json.JsonSerializer.CreateDefault()'.
   at TimeZoneNames.TimeZoneData.Load()
   at TimeZoneNames.TZNames..cctor()
   --- End of inner exception stack trace ---
   at TimeZoneNames.TZNames.GetLanguageKey(String languageCode)
   at TimeZoneNames.TZNames.GetCountryNames(String languageCode)

Updating Newtonsoft.Json to 6.0.1 or higher resolves the problem. The next release should increase the minimum dependency, or otherwise work around this issue.