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

Verification library working with .net 4.7 or Asp .net 4.7 #333

Closed
LindaLawton opened this issue Dec 3, 2021 · 3 comments
Closed

Verification library working with .net 4.7 or Asp .net 4.7 #333

LindaLawton opened this issue Dec 3, 2021 · 3 comments
Labels
question Further information is requested

Comments

@LindaLawton
Copy link

I have spent all day trying to get this library working with .Net 4.7.

The first thing I did was take your webs sample and try convert it to Asp .Net 4.7 and it will not build, at all! I can verify that it works with ,net 5.

So I thought I would take a step back and try with just a console application, seeing as it has been a while since I have worked with Asp .Net 4.7 maybe I was doing something wrong. This sample below again from yours appears to work fine with .Net 5 when it try to run it using .Net 4.7 I get the following error

Console Error

System.IO.FileLoadException: Could not load file or assembly 'Google.Apis.Core, Version=1.53.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)
File name: 'Google.Apis.Core, Version=1.53.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'
at Google.Ads.GoogleAds.Config.GoogleAdsConfig..ctor()
at Google.Ads.GoogleAds.Lib.GoogleAdsClient..ctor()
at ConsoleApplication1.Program.GetKeywordStats.Main(String[] args) in C:\YouTube\RiderProjects\GoogleAdsAPi\ConsoleApplication1\Program.cs:line 54

Code

using System;
using System.Collections.Generic;
using CommandLine;
using Google.Ads.GoogleAds;
using Google.Ads.GoogleAds.Examples;
using Google.Ads.GoogleAds.Lib;
using Google.Ads.GoogleAds.V9.Errors;
using Google.Ads.GoogleAds.V9.Services;

namespace ConsoleApplication1
{
    internal class Program
    {
         /// <summary>
    /// This code example illustrates getting keyword stats.
    /// </summary>
    public class GetKeywordStats : ExampleBase
    {
        /// <summary>
        /// Command line options for running the <see cref="GetKeywordStats"/> example.
        /// </summary>
        public class Options : OptionsBase
        {
            /// <summary>
            /// The Google Ads customer Id.
            /// </summary>
            [Option("customerId", Required = true, HelpText =
                "The Google Ads customer ID for which the call is made.")]
            public long CustomerId { get; set; }
        }

        /// <summary>
        /// Main method, to run this code example as a standalone application.
        /// </summary>
        /// <param name="args">The command line arguments.</param>
        public static void Main(string[] args)
        {
            Options options = new Options();
            CommandLine.Parser.Default.ParseArguments<Options>(args).MapResult(
                delegate (Options o)
                {
                    options = o;
                    return 0;
                }, delegate (IEnumerable<Error> errors)
                {
                    // The Google Ads customer ID for which the call is made.
                    options.CustomerId = long.Parse("xxx");

                    return 0;
                });

            GetKeywordStats codeExample = new GetKeywordStats();
            Console.WriteLine(codeExample.Description);
            codeExample.Run(new GoogleAdsClient(), options.CustomerId);
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description =>
            "This code example illustrates getting keyword stats.";

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        // [START get_keyword_stats]
        public void Run(GoogleAdsClient client, long customerId)
        {
            // Get the GoogleAdsService.
            GoogleAdsServiceClient googleAdsService = client.GetService(
                Services.V9.GoogleAdsService);

            // Create the query.
            string query =
                @"SELECT
                 campaign.id,
                 campaign.name,
                 ad_group.id,
                 ad_group.name,
                 ad_group_criterion.criterion_id,
                 ad_group_criterion.keyword.text,
                 ad_group_criterion.keyword.match_type,
                 metrics.impressions,
                 metrics.clicks,
                 metrics.cost_micros
             FROM keyword_view
             WHERE segments.date DURING LAST_7_DAYS
                 AND campaign.advertising_channel_type = 'SEARCH'
                 AND ad_group.status = 'ENABLED'
                 AND ad_group_criterion.status IN ('ENABLED','PAUSED')
             ORDER BY metrics.impressions DESC
             LIMIT 50";

            try
            {
                // Issue a search request.
                googleAdsService.SearchStream(customerId.ToString(), query,
                    delegate (SearchGoogleAdsStreamResponse resp)
                    {
                        // Display the results.
                        foreach (GoogleAdsRow criterionRow in resp.Results)
                        {
                            Console.WriteLine(
                                "Keyword with text " +
                                $"'{criterionRow.AdGroupCriterion.Keyword.Text}', match type " +
                                $"'{criterionRow.AdGroupCriterion.Keyword.MatchType}' and ID " +
                                $"{criterionRow.AdGroupCriterion.CriterionId} in ad group " +
                                $"'{criterionRow.AdGroup.Name}' with ID " +
                                $"{criterionRow.AdGroup.Id} in campaign " +
                                $"'{criterionRow.Campaign.Name}' with ID " +
                                $"{criterionRow.Campaign.Id} had " +
                                $"{criterionRow.Metrics.Impressions.ToString()} impressions, " +
                                $"{criterionRow.Metrics.Clicks} clicks, and " +
                                $"{criterionRow.Metrics.CostMicros} cost (in micros) during the " +
                                "last 7 days.");
                        }
                    }
                );
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
        // [END get_keyword_stats]
    }
    }
}

I have tried multiple versions of 'Google.Apis.Core' even though it is in my project its not able to pick it up.

Can i get some verification that the library does still work and you have not simply forgotten to remove the support.

@LindaLawton LindaLawton added the question Further information is requested label Dec 3, 2021
@AnashOommen
Copy link
Member

AnashOommen commented Dec 3, 2021 via email

@AnashOommen
Copy link
Member

@LindaLawton I suspect the issue you see is the same as #348. Could you try adding the bindingredirects in the app.config and see if that fixes the issue?

@AnashOommen
Copy link
Member

@LindaLawton please feel free to reopen if you continue to face issues.

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

No branches or pull requests

2 participants