Aggregate exception when calling GetApplicationDefaultAsync ()

I am trying to run a sample Vision API project. I basically copied and pasted the Program.cs code into my application and executed it.

This line (line No. 36- # 37 in Program.cs )

 GoogleCredential credential = GoogleCredential.GetApplicationDefaultAsync().Result; 

throws a System.AggregateException in mscorlib.dll using Additional information: One or more errors occurred. .

Having examined InnerException , I found that the actual exception was an InvalidOperationException with Error deserializing JSON credential data. .

However, my cloud project is a basic project that includes a service account and Cloud Vision API, nothing more. I checked that my environment variable was set to a JSON file by writing:

 Console.WriteLine(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS")); 

before the line above. The result of this (just before the crash) is (something like):

C:\Users\me\Documents\Projects\MyProject\MyProject-ba31aae6efa1.json

I checked the file and this is the file that I received when I turned on my service account. Each property in it looks normal (i.e. the project name is correct, the correct path, ...).

I installed the Google Cloud SDK and executed gcloud beta auth application-default login and allowed access to my cloud account.

Any ideas on what could be causing this?

+8
c # google-cloud-platform google-cloud-vision
source share
1 answer

After examining the detailed build log, I found out that the packages for the Google APIs are dependent on Newtonsoft.Json version 9.0.1 (the latter at the time of this writing).

For some reason, Google API packages have a dependency (which is installed with them) on Newtonsoft.Json version 7.0.0 .

Packages came with the wrong version!

Installing the latest version ( 9.0.1 in this case) fixes the problem.

+5
source share

All Articles