The nuget package Google.Apis.Auth
adds a reference in my project to Google.Apis.Auth.PlatformServices
, but the dll version from nuget is 1.9.1.12399
and it seems that Google.Apis.Auth
needs version 1.9.1.12397
instead as you can see in the exception thrown below.
I tried to add <bindingRedirect oldVersion="1.9.1.12397" newVersion="1.9.1.12399" />
to app.config and machine.config but it won't work.
This is the exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Google.Apis.PlatformServices, Version=1.9.1.12397, Culture=neutral, PublicKeyToken=null' or on
e of its dependencies. The system cannot find the file specified.
File name: 'Google.Apis.PlatformServices, Version=1.9.1.12397, Culture=neutral, PublicKeyToken=null'
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsyncCore>d__e.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsyncCore(Initializer initializer, IEnumerable`1 scopes, String user, CancellationToken task
CancellationToken, IDataStore dataStore)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__1.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 59
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at GoogleTasker.Program.<>c__DisplayClass4.<<Main>b__0>d__6.MoveNext() in c:\Users\User\Documents\Visual Studio 2013\Projects\GoogleTasker\GoogleTasker\Progr
am.cs:line 29
=== Pre-bind state information ===
LOG: DisplayName = Google.Apis.PlatformServices, Version=1.9.1.12397, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///c:/users/user/documents/visual studio 2013/Projects/GoogleTasker/GoogleTasker/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Google.Apis.Auth.PlatformServices, Version=1.9.1.12399, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\user\documents\visual studio 2013\Projects\GoogleTasker\GoogleTasker\bin\Debug\GoogleTasker.vshost.exe.Confi
g
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/GoogleTasker/GoogleTasker/bin/Debug/Google.Apis.PlatformServices
.DLL.
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/GoogleTasker/GoogleTasker/bin/Debug/Google.Apis.PlatformServices
/Google.Apis.PlatformServices.DLL.
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/GoogleTasker/GoogleTasker/bin/Debug/Google.Apis.PlatformServices
.EXE.
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/GoogleTasker/GoogleTasker/bin/Debug/Google.Apis.PlatformServices
/Google.Apis.PlatformServices.EXE.
And this is my code:
static void Main(string[] args)
{
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
Task.Run(async () =>
{
try
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { "https://www.googleapis.com/auth/tasks" },
"user",
CancellationToken.None,
new FileDataStore("Store")
);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
}
);
}
}
App.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.28.0" newVersion="4.2.28.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth.PlatformServices" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="1.9.1.12397" newVersion="1.9.1.12399" />
</dependentAssembly>
</assemblyBinding>
</runtime>