googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.

Home Page:https://developers.google.com/google-ads/api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual Studio setup project dependencies error

rhw2012 opened this issue · comments

I’m using Visual Studio 2019 (C# language, .NET Framework 4.8). To try to troubleshoot this issue, I created a new solution and added a class library project and added a reference to Google.Ads.GoogleAds version 10.2.0.0 using Nuget. It installed all the necessary dependencies (or so I thought). I created a setup project and added the primary output from the class library project. Cleaned and rebuilt. It does successfully build; however, I noticed several lines like below:

WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.PRIMITIVES' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.PRIMITIVES' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.FileProviders.Physical.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.FILEPROVIDERS.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.FileProviders.Physical.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.FILESYSTEMGLOBBING' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.FileProviders.Physical.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.FILEPROVIDERS.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.Json.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.Json.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.Json.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION.FILEEXTENSIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.Json.dll'
WARNING: Unable to find dependency 'SYSTEM.MEMORY' (Signature='CC7B13FFCD2DDD51' Version='4.0.1.0') of assembly 'Microsoft.Extensions.Primitives.dll'
WARNING: Unable to find dependency 'SYSTEM.BUFFERS' (Signature='CC7B13FFCD2DDD51' Version='4.0.2.0') of assembly 'Grpc.Core.dll'
WARNING: Unable to find dependency 'GOOGLE.PROTOBUF' (Signature='A7D26565BAC4D604' Version='3.15.8.0') of assembly 'Google.Api.Gax.Grpc.dll'
WARNING: Unable to find dependency 'SYSTEM.VALUETUPLE' (Signature='CC7B13FFCD2DDD51' Version='4.0.2.0') of assembly 'Google.Api.Gax.Grpc.dll'
WARNING: Unable to find dependency 'SYSTEM.THREADING.TASKS.EXTENSIONS' (Signature='CC7B13FFCD2DDD51' Version='4.2.0.0') of assembly 'Google.Api.Gax.Grpc.dll'
WARNING: Unable to find dependency 'SYSTEM.VALUETUPLE' (Signature='CC7B13FFCD2DDD51' Version='4.0.2.0') of assembly 'Google.Api.Gax.dll'
WARNING: Unable to find dependency 'SYSTEM.RUNTIME.COMPILERSERVICES.UNSAFE' (Signature='B03F5F7F11D50A3A' Version='4.0.4.1') of assembly 'Google.Protobuf.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.FileExtensions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.FILEPROVIDERS.PHYSICAL' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.FileExtensions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.FILEPROVIDERS.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.FileExtensions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.PRIMITIVES' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.FileExtensions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.CONFIGURATION.ABSTRACTIONS' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.FileExtensions.dll'
WARNING: Unable to find dependency 'SYSTEM.THREADING.TASKS.EXTENSIONS' (Signature='CC7B13FFCD2DDD51' Version='4.2.0.0') of assembly 'Microsoft.Bcl.AsyncInterfaces.dll'
WARNING: Unable to find dependency 'GOOGLE.APIS.AUTH' (Signature='4B01FA6E34DB77AB' Version='1.46.0.0') of assembly 'Grpc.Auth.dll'
WARNING: Unable to find dependency 'GOOGLE.PROTOBUF' (Signature='A7D26565BAC4D604' Version='3.15.8.0') of assembly 'Google.Api.CommonProtos.dll'
WARNING: Unable to find dependency 'SYSTEM.RUNTIME.COMPILERSERVICES.UNSAFE' (Signature='B03F5F7F11D50A3A' Version='4.0.4.1') of assembly 'System.Threading.Tasks.Extensions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.PRIMITIVES' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.FileProviders.Abstractions.dll'
WARNING: Unable to find dependency 'MICROSOFT.EXTENSIONS.PRIMITIVES' (Signature='ADB9793829DDAE60' Version='3.1.0.0') of assembly 'Microsoft.Extensions.Configuration.Abstractions.dll'
WARNING: Unable to find dependency 'SYSTEM.RUNTIME.COMPILERSERVICES.UNSAFE' (Signature='B03F5F7F11D50A3A' Version='4.0.4.1') of assembly 'System.Memory.dll'
WARNING: Unable to find dependency 'GOOGLE.PROTOBUF' (Signature='A7D26565BAC4D604' Version='3.15.8.0') of assembly 'Google.LongRunning.dll'
WARNING: Unable to find dependency 'SYSTEM.VALUETUPLE' (Signature='CC7B13FFCD2DDD51' Version='4.0.2.0') of assembly 'System.Text.Json.dll'
WARNING: Unable to find dependency 'SYSTEM.THREADING.TASKS.EXTENSIONS' (Signature='CC7B13FFCD2DDD51' Version='4.2.0.0') of assembly 'System.Text.Json.dll'
WARNING: Unable to find dependency 'SYSTEM.BUFFERS' (Signature='CC7B13FFCD2DDD51' Version='4.0.2.0') of assembly 'System.Text.Json.dll'

If I try to run actual code using GoogleAds with these errors present in the log, it will not run. What am I missing? Am I using the wrong versions of the dependencies?

Could you share a demo project so I can troubleshoot further?

Perhaps try doing a .NET restore once more and do a rebuild? I tried with Visual Studio 2022 and .NET Framework 4.8, and it works fine. I've attached a project. Could you compare with Visual Studio 2019 to see if there's a difference? There shouldn't be any, except for the tool version number that Visual Studio adds.
ConsoleApp1.zip

You need to run

nuget restore ConsoleApp1.sln
msbuild ConsoleApp1.sln

HI,

The attachment is missing... Could you upload again?

Downloaded it from GitHub. Checking...

I think the problem is that when you create an ASP.NET (.NET Framework) project that depends on a class library that depends on Google.Ads.GoogleAds, then Visual Studio doesn't add the necessary binding redirects in the ASP.NET project's web.config. The Google libraries are all compiled at different points in time, so sometimes they cause dependency conflicts.

Try adding the following node to your web.config. The easiest way to get a full up-to-date list is as follows.

  1. Create an empty ASP.NET project.
  2. Add a nuget reference to Google.Ads.GoogleAds.
  3. Copy whatever redirects that Visual Studio inserts into your web.config and put it in your web application's web.config.

I'll add some documentation around this topic, if this workaround fixes the issue for you.

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.18.1.0" newVersion="3.18.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.53.0.0" newVersion="1.53.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.FileProviders.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.FileSystemGlobbing" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.FileProviders.Physical" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Configuration.FileExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Hi,

Could you turn on logging by using the instructions at https://developers.google.com/google-ads/api/docs/client-libs/dotnet/logging and post a request ID? I suspect that this is due to a wrong login-customer-id being used, but the easiest way to verify that is by looking at the logs.

@rhw2012 what email address did you use to generate the OAuth2 access token? Can you mail me directly at anash@google.com? The request itself seems fine, but the error suggests you are using the wrong email address.