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

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

Jon Skeet
people
quotationmark

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.

people

See more on this question at Stackoverflow