.NET NuGet package Config file structure changes?

209 views
Skip to first unread message

David Goldstein

unread,
Aug 18, 2022, 4:46:56 PM8/18/22
to google-doubleclick...@googlegroups.com
I’m in the process of updating my C# .NET applications from v202108 to v202208 of the Google Ads APIs.  I’m using the Google.Dfp package from NuGet, maintained by Anash Oommen, Christopher Seeley, and Jon Imperiosi, as I have been for the last several years.
 
Every time I apply an update, I have a mess to clean up in my App.config files.  Usually I just have to remove extra copies of settings that have been added with default values as part of applying the NuGet package; the way the package’s code is structured, it insists on getting these settings from fixed fields in its own section of the config file, rather than having them passed into constructors or factory methods as parameters.  But this time is different.
 
Applying the NuGet package actually removed the following declarations from the <configSections> block:
    <section name="AdManagerApi" type="System.Configuration.DictionarySectionHandler" />
    <section name="system.diagnostics" type="System.Diagnostics.SystemDiagnosticsSection" />
…and made a number of changes to the contents of the sections referenced: it removed some instructional comments and “Settings related to general library behaviour” from the <AdManagerApi> block, removed two of three <source> entries from the <system.diagnostics><sources> block, removed some required properties from the <source> tag of the remaining block along with one the two settings within the block, and entirely removed the <system.diagnostics><switches> block.
 
The questions I have to resolve are:
  1. What parts of this removed or altered configuration code do I need to reinstate?
  2. Which of the removed configuration settings, and unremoved settings in the sections whose declarations were removed, have been replaced by parameters to constructors or factory methods, or by object properties?
  3. If I reinstate the removed declarations and keep the settings that were not removed, will the values in those settings be picked up automatically as they have been from the beginning, or will I need to read them from the configuration myself and apply them in the code another way?
 
The retained settings in the <AdManagerApi> block are:
  • ApplicationName
  • NetworkCode
  • OAuth2ClientId
  • OAuth2ClientSecret
  • OAuth2JwtCertificatePassword
  • OAuth2JwtCertificatePath
  • OAuth2Mode
  • OAuth2SecretsJsonPath
  • OAuth2ServiceAccountEmail
 
The removed settings in the <AdManagerApi> block are:
  • MaskCredentials
  • EnableGzipCompression
  • IncludeUtilitiesInUserAgent
  • ProxyServer
  • ProxyUser
  • ProxyPassword
  • ProxyDomain
  • AuthorizationMethod
  • OAuth2RefreshToken
 
Thanks,
-David
 

Ad Manager API Forum Advisor

unread,
Aug 19, 2022, 3:54:27 AM8/19/22
to google-doubleclick...@googlegroups.com
Hi David,

Thank you for reaching out to the Ad Manager API support team, this is Anjali.

I have raised this issue with the rest of our team and one of our teammates will reach out to you once we get an update on this.

Regards,
Google Logo
Anjali
Ad Manager API Team
 

 

ref:_00D1U1174p._5004Q2dlMjv:ref

David Goldstein

unread,
Aug 25, 2022, 1:38:31 PM8/25/22
to Ad Manager API Forum Advisor, google-doubleclick...@googlegroups.com

Hi, Anjali.

 

Have there been any updates?

I am running out of time to resolve this in before it starts impacting other projects.

 

Thanks,

-David

 

From: 'Ad Manager API Forum Advisor' via Google Ad Manager API Forum <google-doubleclick...@googlegroups.com>
Sent: Friday, August 19, 2022 3:54 AM
To: google-doubleclick...@googlegroups.com
Subject: [External] RE: .NET NuGet package Config file structure changes?

 

 

CAUTION: This email originated from outside of the organization. This message might not be safe, use caution in opening it. If in doubt, do not open the attachment nor links in the message.

 

--
You received this message because you are subscribed to the Google Groups "Google Ad Manager API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-doubleclick-for-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-doubleclick-for-publishers-api/bmGaq000000000000000000000000000000000000000000000RGURAJ00IKVohVrSQECOuZyUGvQ7ww%40sfdc.net.

Anash Oommen

unread,
Aug 25, 2022, 4:27:02 PM8/25/22
to Google Ad Manager API Forum
Hi David,

I'll ask Chris to chime in as well, but from an initial glance,

1. You need to reinstall the <system.diagnostics> node if you need to capture the API call logs. Otherwise you can leave it out. You can copy and reinstate the values from https://github.com/googleads/googleads-dotnet-lib/blob/master/src/AdManager/App.config.

2. In general, if you reinstate the removed declarations and keep the settings that were not removed, the values in those settings be picked up automatically as they have been from the beginning. No need to apply these settings in the code in any other way.

From the list of keys you provided, I'm guessing that you use a service account flow to make your API calls. If that's the case, it is fine to let the following keys stay removed if it simplifies things for you. They all have standard default values,  and the library will work fine with those default values. You only need to add these optional settings if you have a non-standard setup and have been advised by the support team to override one or more of these settings.
  • MaskCredentials
  • EnableGzipCompression
  • IncludeUtilitiesInUserAgent
  • ProxyServer
  • ProxyUser
  • ProxyPassword
  • ProxyDomain
  • AuthorizationMethod
  • OAuth2RefreshToken
Hope this helps?

Regards
Anash P. Oommen,
Ads Developer Relations, Google

David Goldstein

unread,
Aug 26, 2022, 3:25:26 PM8/26/22
to Anash Oommen, Google Ad Manager API Forum

Thanks, Anash.  That helps tremendously.

 

But now I’m running into an execution problem.  When I try to create a new Google.Api.Ads.AdManager.Lib.AdManagerUser():

 

The version of Google.Apis.Core that I have installed for this VS project is 1.57.0, not 1.49.0, and the config files had no reference to 1.49.0 of Google.Apis.Core, only to 1.57.0.  I found a few references to Google.Apis version I found for Google.Apis in some config files, and manually changed them to 1.57.0 because that’s the version actually installed, and it didn’t help.

 

Here’s the stack trace:

   at Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl..ctor(AppConfig config)

   at Google.Api.Ads.Common.Lib.AdsUser.SetOAuthProvider(AppConfigBase config)

   at Google.Api.Ads.Common.Lib.AdsUser..ctor(AppConfigBase config, Dictionary`2 headers)

   at Google.Api.Ads.AdManager.Lib.AdManagerUser..ctor()

   at GoogleDoubleClickBrowser.GoogleDoubleClickQuerier.LoadCredentials(String NetworkCode) in ...\GoogleDoubleClickReporting\GoogleDoubleClickAPI.cs:line 309

 

Again, I’ve updated Google.Dfp from 24.16.0 to 24.20.0, and Google.Ads.Common from 9.5.1 to 9.5.2.

 

These are the Google packages I have installed:

 

(I generally update BouncyCastle last, after confirming everything works without the update, as in the past some updates to it have been incompatible with Google.Dfp.)

 

I’ve tried making it redownload all of the packages from NuGet, and even tried making it reinstall first some that Visual Studio produced warnings for as being meant for older versions of .NET Framework than I’m using (currently using 4.8), and the Google ones, and this hasn’t made any difference.

 

Any thoughts on what might be causing it to look for 1.49.0?

 

Thanks,

-David

Anash Oommen

unread,
Aug 26, 2022, 4:00:21 PM8/26/22
to Google Ad Manager API Forum
Hi David,

Check your App.config. If I were to guess, there's some bad bindingRedirect in your App.config due to the previous issue.

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      ...
      <dependentAssembly>
        <assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.57.0.0" newVersion="1.57.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


Regards
Anash

David Goldstein

unread,
Aug 26, 2022, 4:09:54 PM8/26/22
to Anash Oommen, Google Ad Manager API Forum

I found these:

 

      <dependentAssembly>

        <assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-1.57.0.0" newVersion="1.57.0.0" />

      </dependentAssembly>

      <dependentAssembly>

        <assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-1.57.0.0" newVersion="1.57.0.0" />

      </dependentAssembly>

      <dependentAssembly>

        <assemblyIdentity name="Google.Ads.Common" publicKeyToken="52807268f2b614dc" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />

      </dependentAssembly>

      <dependentAssembly>

 

The 1.57.0.0 is correct; it matches what I have installed.

I had found an entry for Google.Apis which inappropriately referred to 1.49.0.0, but not for Google.Apis.Core.

 

That said…  Google.Ads.Common should be 9.5.2.0, not 8.0.0.0.

 

I also found this in the config file of a different application, that I’d updated at the same time:

      <dependentAssembly>

        <assemblyIdentity name="Google.Apis.PlatformServices" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-1.16.0.0" newVersion="1.16.0.0" />

      </dependentAssembly>

I don’t even have a package called Google.Apis.PlatformServices installed.

 

Should I be just removing these entries entirely rather than trying to update them?

Anash Oommen

unread,
Aug 26, 2022, 5:13:13 PM8/26/22
to Google Ad Manager API Forum
Hi David,

Comment out the Google.Apis.PlatformServices dependency if you don't use it. Google.Apis and Google.Apis.Core are compiled and released together, so it is expected that if their versions are out of sync through a bindingRedirect, then there will be issues similar to the one you experienced.

Regards
Anash

David Goldstein

unread,
Aug 26, 2022, 5:31:22 PM8/26/22
to Anash Oommen, Google Ad Manager API Forum

Commenting out the <dependentAssembly> entries for Google-related libraries seems to have resolved the problem.

 

What makes this strange is that it produced errors even when the version numbers in the <bindingRedirect> tags referencing Google.Apis and Google.Apis.Core matched the installed versions of the NuGet packages.

Anash Oommen

unread,
Aug 26, 2022, 6:28:03 PM8/26/22
to David Goldstein, Google Ad Manager API Forum
Hi David,

Binding redirects are a thing that Microsoft introduced in .NET 4.5 due to the heavy burden that the .NET Framework was developing at that time due to backward compatibility reasons. It disappeared in .NET Core and .NET5+.

If you know you are using a set of assemblies that work well together, you can just disable it. See https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection for some background.

Regards
Anash
Reply all
Reply to author
Forward
0 new messages