Unable to run Google Cloud PubSub in c#, DLL problems

2

I am working on integrating Google Cloud PubSub into my c# project, I used NuGet to install 1.0.0-beta11, no errors at all. When I run my project and when it reaches the code that uses pubsub, I get the following error:

An unhandled exception of type 'System.IO.FileLoadException' occurred in 
 Google.Api.Gax.dll

Additional information: Could not load file or assembly 'Google.Apis.Auth, Version=1.21.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

NuGet did install all the dependencies including Google.Apis.Auth.dll, but it's 1.27.1. I have tried everything I could think of, including grabbing 1.21.0 of that dll and using that, but no success. I have been able to run the .net sample just fine with no error.

Any thoughts? Let me know if you need more info

c#
nuget
google-cloud-pubsub
asked on Stack Overflow Jun 27, 2017 by Hammy • edited Jun 27, 2017 by Hammy

3 Answers

2

Okay, I've found the reference to Google.Apis.Auth 1.21.0 - it's in the Grpc.Auth NuGet package.

If you just add a reference to the Grpc.Auth DLL, you'll get this kind of failure - but if you manage all the dependencies via NuGet, I'd expect it to be okay - it should add assembly binding redirects for you.

Without knowing your exact setup, it's quite tricky to say more than that - it could be that your library needs assembly binding redirects, but the application is in control of them... and in particular, if your application only has a reference to the library DLL, that would cause the problem.

As a workaround, you could either manually add the assembly binding redirects (the exact way of doing that will depend on the application type) or just add a reference to Google.Cloud.PubSub.V1 in the application as well as the library, at which point NuGet will do all the dependency handling for you.

answered on Stack Overflow Jun 29, 2017 by Jon Skeet
1

You can append the following to your app.config file.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
      <bindingRedirect oldVersion="1.21.0.0-1.35.1.0" newVersion="1.35.1.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>
answered on Stack Overflow Aug 7, 2018 by Mr_Sven
0

Old issue but maybe will help someone in the future. Was stuck with it also, it's indeed the bindingRedirect issue. In my case it was that the app.config was at the wrong level, just at the project level.

Good luck

answered on Stack Overflow Apr 26, 2020 by Inga

User contributions licensed under CC BY-SA 3.0