问题
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