-
Notifications
You must be signed in to change notification settings - Fork 199
Specifying separate App.config for client library
By default, the Ads API .NET library gets its configuration from the application's App.config / Web.config
. However, if you don't want to get your App.config
cluttered, you could move the library-specific configuration into its own configuration file using the configSource property.
Modify your App.config
to look like this:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler"/> </configSections> <AdWordsApi configSource="AdWordsApi.config"/> … </configuration>
The section name and the configSource depends on the API for which you are specifying configSource
.
- For AdWords and AdxBuyer APIs, it should be
AdWordsApi
andAdWordsApi.config
respectively. - For Google Ad Manager API, it should be
AdManagerApi
andAdManagerApi.config
respectively.
Now create another config file with the name you specified on configSource
, and move the configuration node from your App.config
into this file, as follows:
<?xml version="1.0" encoding="utf-8" ?>
<AdWordsApi>
… More settings
</AdWordsApi>
The configuration node you move depends on the API for which you are specifying configSource
.
- For AdWords and AdxBuyer APIs, the node to move is
AdWordsApi
. - For Google Ad Manager API, the node to move is
AdManagerApi
.
Finally, include new configuration file in your project. Change the properties of this file to Always copy to output folder.
Now build and run your project. Your application will start picking up values from the new configuration file.