I am working on integrating Google Cloud PubSub into a sample C # project, I am new to C #, as this is likely to be the only C # project that I will work on in my company, due to some requirements for integration with a game written in c #. I used NuGet to install Google.Cloud.PubSub.V1.0.0-beta13 , and the installation was successful, however, when I try to run the sample code created using the documents, I get the following error:
C:/Users/MyUser/RiderProjects/TestConsole/TestConsole/bin/Debug/TestConsole.exe Unhandled Exception: System.IO.FileLoadException: 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 manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Google.Api.Gax.TaskExtensions.WaitWithUnwrappedExceptions(Task task) in C:\Users\jon\Test\Projects\gax-dotnet\releasebuild\src\Google.Api.Gax\TaskExtensions.cs:line 48 at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint) in C:\Users\jon\Test\Projects\gax-dotnet\releasebuild\src\Google.Api.Gax.Grpc\ChannelPool.cs:line 92 at Google.Cloud.PubSub.V1.PublisherClient.Create(ServiceEndpoint endpoint, PublisherSettings settings) in C:\Users\jon\Test\Projects\google-cloud-dotnet\releasebuild\apis\Google.Cloud.PubSub.V1\Google.Cloud.PubSub.V1\PublisherClient.cs:line 558 at TestConsole.Program.CreateTopic(String projectId, String topicId) in C:\Users\MyUser\RiderProjects\TestConsole\TestConsole\Program.cs:line 11 at TestConsole.Program.Main(String[] args) in C:\Users\MyUser\RiderProjects\TestConsole\TestConsole\Program.cs:line 32
Then I tried to downgrade Google.Apis.Auth to 1.21.0, but then the problem moved to βGoogle.Api.Gax, Version = 1.0.1.0 Failed to loadβ, and then (if I continue to redefine the dependencies) on Google. Protobuf 3.2.0.0, then to Google.Apis.Core 1.24.1, and then back to "Google.Apis.Auth 1.21.0 failed to load", so I think the problem is in another place.
What causes this addiction problem? If I download the Google Pubsub sample from Github, I don't get any problems even if package.config is the same in my project.
Here is my Program.cs:
using Google.Cloud.PubSub.V1; using Google.Protobuf; namespace TestConsole { internal class Program { public static object CreateTopic(string projectId, string topicId) { var publisher = PublisherClient.Create(); var topicName = new TopicName(projectId, topicId); var message = new PubsubMessage {
and my packages.config
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Google.Api.CommonProtos" version="1.0.0" targetFramework="net452" /> <package id="Google.Api.Gax" version="1.0.1" targetFramework="net452" /> <package id="Google.Api.Gax.Grpc" version="1.0.1" targetFramework="net452" /> <package id="Google.Apis" version="1.24.1" targetFramework="net452" /> <package id="Google.Apis.Auth" version="1.24.1" targetFramework="net452" /> <package id="Google.Apis.Core" version="1.24.1" targetFramework="net452" /> <package id="Google.Cloud.Iam.V1" version="1.0.0-beta09" targetFramework="net452" /> <package id="Google.Cloud.PubSub.V1" version="1.0.0-beta09" targetFramework="net452" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net452" /> <package id="Grpc.Auth" version="1.4.0" targetFramework="net452" /> <package id="Grpc.Core" version="1.4.0" targetFramework="net452" /> <package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net452" /> <package id="System.Net.Http" version="4.3.1" targetFramework="net425" /> <package id="Zlib.Portable.Signed" version="1.11.0" targetFramework="net452" /> </packages>
I am using Rider 2017.1.1 to run my project and I am running it on the .NET Framework 4.5.2.
Please note that I already know that a very similar question has already been sent to this URL. Google Cloud PubSub could not be launched in C #, problems with DLL , but because of my low "reputation" I can not comment on this (you know, I I usually try to read the documentation and look for answers to already asked questions and try to avoid creating duplicates, so I donβt have a high reputation on this site), and the guy who made the question solve the problem by itself, not knowing how to do it. The answer says:
... if you manage all the dependencies through NuGet, I would expect that everything will be alright - it should add binding redirects for you.
which, it seems to me, I'm already doing.