'Google Ads API c# - Multiple custom attributes of the same type found ERROR

Locally the project works, the issue is when released on Azure Web App.

`public List GetAllExpantedTextAds(long adGroupId) { List expandedTextAds = new List();

        GoogleAdsClient client = new GoogleAdsClient();
        GoogleAdsConfig config = (client.Config as GoogleAdsConfig);

        GoogleAdsServiceClient googleAdsService = client.GetService(Services.V10.GoogleAdsService);
        // Create a selector.                
        string searchQuery = $@"SELECT
             ad_group.id,
             ad_group_ad.ad.id,                 
             ad_group_ad.ad.expanded_text_ad.headline_part1,
             ad_group_ad.ad.expanded_text_ad.headline_part2,
             ad_group_ad.ad.expanded_text_ad.path1,
             ad_group_ad.ad.expanded_text_ad.path2,
             ad_group_ad.ad.expanded_text_ad.description,
             ad_group_ad.status
         FROM ad_group_ad
         WHERE
             ad_group_ad.ad.type = EXPANDED_TEXT_AD
             AND ad_group_ad.status = 'ENABLED'";

        if (adGroupId != null)
        {
            searchQuery += $" AND ad_group.id = {adGroupId}";
        }

        // Create a request that will retrieve all ads using pages of the specified page size.
        SearchGoogleAdsRequest request = new SearchGoogleAdsRequest()
        {
            CustomerId = customerId.ToString(),
            PageSize = PAGE_SIZE,
            Query = searchQuery
        };

        //try
        //{
            // Issue the search request.
            PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse =
                googleAdsService.Search(request);

            // Iterates over all rows in all pages and prints the requested field values for
            // the ad in each row.

            foreach (GoogleAdsRow googleAdsRow in searchPagedResponse)
            {
                Ad ad = googleAdsRow.AdGroupAd.Ad;

                ExpandedTextAdInfo expandedTextAdInfo = ad.ExpandedTextAd;

                Console.WriteLine("Expanded text ad with ID {0}, status '{1}', and headline " +
                    "'{2} - {3}' was found in ad group with ID {4}.",
                    ad.Id, googleAdsRow.AdGroupAd.Status, expandedTextAdInfo.HeadlinePart1,
                    expandedTextAdInfo.HeadlinePart2, googleAdsRow.AdGroup.Id);
                // Prints the ad text asset detail.

                expandedTextAds.Add(expandedTextAdInfo);
            }
        //}
        //catch (GoogleAdsException e)
        //{
        //    Console.WriteLine("Failure:");
        //    Console.WriteLine($"Message: {e.Message}");
        //    Console.WriteLine($"Failure: {e.Failure}");
        //    Console.WriteLine($"Request ID: {e.RequestId}");
        //    throw;
        //}

        return expandedTextAds;
    }`

Below follows the error I get.

[AmbiguousMatchException: Multiple custom attributes of the same type found.] System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit) +110 System.Runtime.InteropServices.RuntimeInformation.get_FrameworkDescription() +88

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +190 System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +57 System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +21 Grpc.Core.Internal.PlatformApis.TryGetFrameworkDescription() +83 Grpc.Core.Internal.PlatformApis..cctor() +92

[TypeInitializationException: The type initializer for 'Grpc.Core.Internal.PlatformApis' threw an exception.] Grpc.Core.Internal.PlatformApis.get_FrameworkDescription() +0 Grpc.Core.Internal.UserAgentStringProvider..cctor() +25

[TypeInitializationException: The type initializer for 'Grpc.Core.Internal.UserAgentStringProvider' threw an exception.] Grpc.Core.Internal.UserAgentStringProvider.get_DefaultInstance() +0 Grpc.Core.Channel.EnsureUserAgentChannelOption(Dictionary2 options) +89 Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable1 options) +169 Grpc.Core.Channel..ctor(String host, Int32 port, ChannelCredentials credentials, IEnumerable1 options) +68 Google.Ads.GoogleAds.Lib.CachedChannelFactory.CreateChannel(GoogleAdsConfig config) +567 Google.Ads.GoogleAds.Lib.CachedChannelFactory.GetChannel(GoogleAdsConfig config) +882 Google.Ads.GoogleAds.Lib.GoogleAdsServiceClientFactory.CreateChannel(GoogleAdsConfig config) +71 Google.Ads.GoogleAds.Lib.GoogleAdsServiceClientFactory.GetService(ServiceTemplate2 serviceTemplate, GoogleAdsConfig config) +102 Google.Ads.GoogleAds.Lib.GoogleAdsClient.GetService(ServiceTemplate`2 serviceTemplate) +170 portalcouponology.Classes.GoogleAdsAPI.GetAllExpantedTextAds(Int64 adGroupId) in D:\a\9\s\portalcouponology\Classes\GoogleAdsAPI.cs:810 portalcouponology.pages.store.WebForm1.loadGoogleAds(String custid) in D:\a\9\s\portalcouponology\pages\store\edit-merchant.aspx.cs:82 portalcouponology.pages.store.WebForm1.Page_Load(Object sender, EventArgs e) in D:\a\9\s\portalcouponology\pages\store\edit-merchant.aspx.cs:42 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +85 System.Web.UI.Control.OnLoad(EventArgs e) +79 System.Web.UI.Control.LoadRecursive() +130 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2850



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source