Google.Apis.Json.NewtonsoftJsonSerializer throw an exception

点点圈 提交于 2019-12-13 01:03:38

问题


When I run workerRole on Azure, throw me the following exception:

An unhandled exception of type 'System.TypeInitializationException' occurred in Google.Apis.Auth.dll

Additional information: Se produjo una excepción en el inicializador de tipo de 'Google.Apis.Json.NewtonsoftJsonSerializer'.

This is the code that break execution:

private static byte[] jsonSecrets = Properties.Resources.client_secrets;

using (var stream = new MemoryStream(jsonSecrets, true))
{
     GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
     credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
     GoogleClientSecrets.Load(stream).Secrets,
          new[] { BigqueryService.Scope.Bigquery, BigqueryService.Scope.CloudPlatform },
          "user",
          CancellationToken.None,
          new FileDataStore("Bigquery.Auth.Store")).Result;
}

I know that the "GoogleClientSecrets.Load(stream).Secrets" throws the exception because method Load() returns null value, but stream is full. Anybody have a idea?

Thanks, Roger

EDIT:

{System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'Google.Apis.Json.NewtonsoftJsonSerializer'. ---> System.IO.FileLoadException: No se puede cargar el archivo o ensamblado 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ni una de sus dependencias. La definición del manifiesto del ensamblado no coincide con la referencia al ensamblado. (Excepción de HRESULT: 0x80131040) en Google.Apis.Json.NewtonsoftJsonSerializer..cctor() --- Fin del seguimiento de la pila de la excepción interna --- en Google.Apis.Json.NewtonsoftJsonSerializer.get_Instance() en Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(Stream stream) en c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis.Auth\OAuth2\GoogleClientSecrets.cs:línea 55 en AzureConnection.BigQueryCon.getAuth() en c:\Users\user\Documents\AzureConnection\AzureConnection\BigQueryCon.cs:línea 34}

来源:https://stackoverflow.com/questions/21581756/google-apis-json-newtonsoftjsonserializer-throw-an-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!