Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load file or assembly 'Google.Apis.Auth, Version=1.36.1.0 #210

Open
AngelVenchev opened this issue Mar 29, 2019 · 8 comments
Open
Labels

Comments

@AngelVenchev
Copy link

I am having the same issue as in the following issue #208

However, I am not updating I am adding those dependencies for the first time. I am unable to run an example successfully. I added the required configuration to a config file extracted an IConfigurationSection out of it and created an AdWordsUser to run the example.

var config = new AdWordsAppConfig(section);
codeExample.Run(new AdWordsUser(config));

The configuration settings get loaded successfully, but I get the following error:

System.IO.FileLoadException: Could not load file or assembly 'Google.Apis.Auth, Version=1.36.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)
File name: 'Google.Apis.Auth, Version=1.36.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'
   at Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RefreshAccessTokenInOfflineMode()
   at Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GetAuthHeader()
   at Google.Api.Ads.Common.OAuth.OAuthClientMessageInspector.BeforeSendRequest(Message& request, IClientChannel channel)
   at System.ServiceModel.Dispatcher.ImmutableClientRuntime.BeforeSendRequest(ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.PrepareCall(ProxyOperationRuntime operation, Boolean oneway, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetMethod, Object[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
   at generatedProxy_1.get(Selector )
   at Google.Api.Ads.AdWords.Examples.CSharp.v201806.GetCampaigns.Run(AdWordsUser user) in C:\Projects\aws-csharp-vs\FirstApiCall.cs:line 79
@mabead
Copy link

mabead commented Nov 8, 2019

Hi @AngelVenchev . Were you able to find a solution to this? I have a similar problem with Google.Cloud.Translate.V3.TranslationServiceClient. My code also results in the exception Could not load file or assembly 'Google.Apis.Auth, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'. An operation is not legal in the current state.

@Bafan
Copy link

Bafan commented Mar 3, 2020

Same error here when I am using AWS mock test tool to test my lamba function localy:

Could not load file or assembly 'Google.Apis.Auth, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)

@maltezc
Copy link

maltezc commented Jul 2, 2020

I'm getting the same error when trying to incorporate with Revit. I use version 1.44.1.0 as a reference DLL and then it also asks me for version 1.21.0.0

@KelvisGama
Copy link

Same error here when I am using AWS mock test tool to test my lamba function localy too!

System.IO.FileLoadException: Could not load file or assembly 'Google.Apis.Auth, Version=1.47.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)

@KelvisGama
Copy link

Same error here when I am using AWS mock test tool to test my lamba function localy too!

System.IO.FileLoadException: Could not load file or assembly 'Google.Apis.Auth, Version=1.47.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)

I've solved this!

The problem, in my case, is that it just doesn't work with AWS mock test tool!
I deployed the lambda and executed directly from the AWS Console and it works perfectly.

@AndreasKoblischke
Copy link

AndreasKoblischke commented Jan 6, 2021

The reason is: The API references both Versions of the Google.Apis.Core DLL. 1.36.1.0 AND the actual one (in my case 1.49.0.0). Its getting really confusing if you load the DLL at runtime. At best using Google Ads where the error is located together with Google Analytics with tends to use the correct DLL reference.

So what to do:

You need to map the old version of Google.Apis.Core 1.36.1.0 to your preferred one. You can do this by adding a bindingRedirect to you app.config (It need to be in your startup project(s). Down in a referred DLL project does not work!)

`

<runtime>

   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

     <dependentAssembly>

       <assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
       <bindingRedirect oldVersion="0.0.0.0-1.36.1.0" newVersion="1.49.0.0" />

     </dependentAssembly>

   </assemblyBinding>

</runtime>

`

@MaazAR24
Copy link

I get this same error when i create a release from cmd but not through vs

@flaviotsales
Copy link

I solved by copying all the local <dependentAssembly> to the server Web.Config.
After the installation of the some Google NuGet packages, there were some modifications/additions to these tags, and it turned out that the contents of the <assemblyBinding> section on the server Web.Config was out of sync with the local one, and was not being updated when deploying (I'm using web deploy), so it was missing some of the <dependentAssembly> tags, although I don't know exactly which of those were the problematic ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants