Google.Apis版本不适用于更新版本的Newtonsoft.Json

时间:2019-10-01 11:04:52

标签: c# google-api json.net google-api-dotnet-client .net-standard-2.0

我正在.NET Framework 4.7.2中的Web应用程序中使用Google .net客户端库版本1.36.1,该版本可与Newtonsoft.Json版本10.0.2一起使用。

我想在我的Web应用程序中包括一个使用Newtonsoft.Json版本12.0.2的.NET Standard 2.0中的类库,但是我不能,因为这是这两个Newtonsoft版本之间的不兼容问题。

我想将Web应用程序中的Newtonsoft.Json从10.0.2升级到12.0.2,但是它说Google.Apis不支持Newtonsoft.Json的较新版本。

我已经在1464

上将此问题添加到客户端库回购中

有什么主意我该如何解决这个问题?也许Google.Apis应该进行升级?

谢谢!

更新:

这是我的详细情况:

我通过NuGet软件包管理器将Newtonsoft.Json更新为12.0.2。在此部分

var certificate = new X509Certificate2(...); const string user =“ ...”; var serviceAccountCredentialInitializer =新的ServiceAccountCredential.Initializer(用户)     {Scopes = new [] {SheetsService.Scope.Drive}} .FromCertificate(certificate); var credential = new ServiceAccountCredential(serviceAccountCredentialInitializer); var service = new SheetsService(new BaseClientService.Initializer() {HttpClientInitializer =凭据,ApplicationName =“我的应用程序名称”});

当我将服务变量初始化为新的SheetsService(...)时,出现以下异常:

无法加载文件或程序集“ Newtonsoft.Json,版本= 10.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)“:” Newtonsoft.Json,版本= 10.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed

Source =“ Google.Apis.Core” 在Google.Apis.Json.NewtonsoftJsonSerializer..ctor()\ r \ n在Google.Apis.Services.BaseClientService.Initializer..ctor()\ r \ n在OmneaHotLead.WriteInSheetToOmnea(Int32 firNr,IList`1 omn​​Data)位于d:\ Projects \ MyApplication \ App_Code \ MyCode.cs:line ...

然后我通过NuGet软件包管理器将Google.Apis软件包更新为1.41.1。而且我还是例外。

0 个答案:

没有答案