Google.Apis version doesn't work with newer version of Newtonsoft.Json

1

I am using Google .net client library version 1.36.1 in a web application in .NET Framework 4.7.2 which works with a Newtonsoft.Json version 10.0.2.

I want to include in my web application a class library in .NET Standard 2.0 which uses Newtonsoft.Json version 12.0.2, but I can't, because is an incompatibility issue between these 2 Newtonsoft version.

I wanted to upgrade the Newtonsoft.Json in web app from 10.0.2 into 12.0.2 but it says the Google.Apis doesn't support the newer version of the Newtonsoft.Json.

I have added this as an issue on the client library repo already 1464

Any idea how can I solve this problem? Maybe Google.Apis should be do an upgrade?

Thanks in advance!

UPDATE:

Here is my detailed scenario:

I updated Newtonsoft.Json to 12.0.2 via NuGet Package Manager. At this section

var certificate = new X509Certificate2(...); const string user = "..."; var serviceAccountCredentialInitializer = new ServiceAccountCredential.Initializer(user) { Scopes = new[] { SheetsService.Scope.Drive } }.FromCertificate(certificate); var credential = new ServiceAccountCredential(serviceAccountCredentialInitializer); var service = new SheetsService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "My Application Name" });

when I initialize the service variable as new SheetsService(...), I got the following exception:

Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed

Source = "Google.Apis.Core" StackTrace = " at Google.Apis.Json.NewtonsoftJsonSerializer..ctor()\r\n at Google.Apis.Services.BaseClientService.Initializer..ctor()\r\n at OmneaHotLead.WriteInSheetToOmnea(Int32 firNr, IList`1 omnData) in d:\Projects\MyApplication\App_Code\MyCode.cs:line...

Then I updated Google.Apis packages via NuGet Package Manager to 1.41.1. And I still got the exception.

c#
google-api
json.net
google-api-dotnet-client
.net-standard-2.0
asked on Stack Overflow Oct 1, 2019 by user7745308 • edited Oct 2, 2019 by user7745308

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0